content/xml/tests/script.xml

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:850e1cd69bca
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="docbook.css" type="text/css"?>
3 <!DOCTYPE Book System "file:///E|/Program%20Files/SoftQuad/XMetaL/Rules/docbook.dtd">
4 <Book xmlns:html="http://www.w3.org/1999/xhtml">
5 <Title>The Book</Title>
6 <Chapter>
7 <Title>Chapter 1.</Title>
8 <Para>Yada yada <html:img src="mzcolor.gif"/> yada.</Para>
9 </Chapter>
10 <html:script>
11 <![CDATA[
12 function list(node)
13 {
14 var type = node.nodeType;
15 if (type == Node.ELEMENT_NODE) {
16
17 // open tag
18 dump("\<" + node.tagName);
19
20 // dump the attributes if any
21 attributes = node.attributes;
22 if (null != attributes) {
23 var countAttrs = attributes.length;
24 var index = 0;
25 while(index < countAttrs) {
26 att = attributes[index];
27 if (null != att) {
28 dump(" " + att.name + "=" + att.value);
29 }
30 index++;
31 }
32 }
33
34 // recursively dump the children
35 if (node.hasChildNodes()) {
36 // close tag
37 dump(">");
38
39 // get the children
40 var children = node.childNodes;
41 var length = children.length;
42 var count = 0;
43 while(count < length) {
44 child = children[count];
45 list(child);
46 count++;
47 }
48 dump("</" + node.tagName + ">");
49 }
50 else {
51 // close tag
52 dump("/>");
53 }
54
55
56 }
57 // if it's a piece of text just dump the text
58 else if (type == Node.TEXT_NODE) {
59 dump(node.data);
60 }
61 }
62
63 list(document.documentElement);
64 dump("\n");
65 ]]>
66 </html:script>
67 </Book>

mercurial