content/xml/tests/script.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xml/tests/script.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="docbook.css" type="text/css"?>
     1.6 +<!DOCTYPE Book System "file:///E|/Program%20Files/SoftQuad/XMetaL/Rules/docbook.dtd">
     1.7 +<Book xmlns:html="http://www.w3.org/1999/xhtml">
     1.8 +  <Title>The Book</Title>
     1.9 +  <Chapter>
    1.10 +    <Title>Chapter 1.</Title>
    1.11 +    <Para>Yada yada <html:img src="mzcolor.gif"/> yada.</Para>
    1.12 +  </Chapter>
    1.13 +  <html:script>
    1.14 +<![CDATA[
    1.15 +function list(node)
    1.16 +{
    1.17 +    var type = node.nodeType;
    1.18 +    if (type == Node.ELEMENT_NODE) {
    1.19 +
    1.20 +        // open tag
    1.21 +        dump("\<" + node.tagName);
    1.22 +
    1.23 +        // dump the attributes if any
    1.24 +        attributes = node.attributes;
    1.25 +        if (null != attributes) {
    1.26 +            var countAttrs = attributes.length;
    1.27 +            var index = 0;
    1.28 +            while(index < countAttrs) {
    1.29 +                att = attributes[index];
    1.30 +                if (null != att) {
    1.31 +                    dump(" " + att.name + "=" + att.value);
    1.32 +                }
    1.33 +                index++;
    1.34 +            }
    1.35 +        }
    1.36 +
    1.37 +        // recursively dump the children
    1.38 +        if (node.hasChildNodes()) {
    1.39 +	    // close tag
    1.40 +            dump(">");
    1.41 +
    1.42 +            // get the children
    1.43 +            var children = node.childNodes;
    1.44 +            var length = children.length;
    1.45 +            var count = 0;
    1.46 +            while(count < length) {
    1.47 +                child = children[count];
    1.48 +                list(child);
    1.49 +                count++;
    1.50 +            }
    1.51 +            dump("</" + node.tagName + ">");
    1.52 +        }
    1.53 +	else {
    1.54 +	    // close tag
    1.55 +            dump("/>");
    1.56 +        }
    1.57 +
    1.58 +        
    1.59 +    }
    1.60 +    // if it's a piece of text just dump the text
    1.61 +    else if (type == Node.TEXT_NODE) {
    1.62 +        dump(node.data);
    1.63 +    }
    1.64 +}
    1.65 +
    1.66 +list(document.documentElement);
    1.67 +dump("\n");
    1.68 +]]>
    1.69 +  </html:script>	
    1.70 +</Book>

mercurial