Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed af84378

Created an initial DTD with a small testcase.

  • Participants
  • Parent commits 4f820a3

Comments (0)

Files changed (3)

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+use IO::All;
+
+use XML::LibXML;
+
+# TEST*1
+foreach my $xml_file (io("./valid-xmls")->all())
+{
+    if ($xml_file =~ /\.xml$/)
+    {
+        my $p = XML::LibXML->new();
+        $p->validation(0);
+        my $dom = $p->parse_file($xml_file);
+        my $dtd =
+            XML::LibXML::Dtd->parse_string(
+                scalar(io("products-syndication.dtd")->slurp())
+            );
+        ok ($dom->validate($dtd));
+    }
+}

File xslt/products-syndication.dtd

+<!ELEMENT product-syndication (meta?,data)>
+<!ELEMENT meta (#PCDATA)>
+<!ELEMENT data (cat)>
+<!ELEMENT cat (title,desc?)>
+<!ELEMENT desc (p*)>
+<!ELEMENT p (#PCDATA)>
+<!ELEMENT title (#PCDATA)>
+<!ATTLIST cat id ID #REQUIRED>

File xslt/valid-xmls/001-empty-cat.xml

+<?xml version='1.0' encoding='utf-8'?>
+<?xml-stylesheet type="text/xml" href="product-syndication.xsl"?>
+<!DOCTYPE comparison SYSTEM "product-syndication.dtd">
+<product-syndication>
+    <data>
+        <cat id="books">
+            <title>Books</title>
+            <desc>
+                <p>
+                    These are my books.
+                </p>
+            </desc>
+        </cat>
+    </data>
+</product-syndication>