You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2002/02/19 20:36:12 UTC
cvs commit: xml-xerces/java/tests/dom/serialize expectedoutput.xml input.xml TestNS.java
elena 02/02/19 11:36:12
Modified: java/tests/dom/serialize expectedoutput.xml input.xml
TestNS.java
Log:
add tests to verify correctness of namespace algorithm
Revision Changes Path
1.2 +22 -0 xml-xerces/java/tests/dom/serialize/expectedoutput.xml
Index: expectedoutput.xml
===================================================================
RCS file: /home/cvs/xml-xerces/java/tests/dom/serialize/expectedoutput.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- expectedoutput.xml 12 Jan 2002 00:11:49 -0000 1.1
+++ expectedoutput.xml 19 Feb 2002 19:36:12 -0000 1.2
@@ -3,6 +3,25 @@
<s:Body>
<length>3</length>
</s:Body>
+
+ <!-- xmlns is removed during the modifications -->
+ <empty xmlns="">
+ <elem/>
+ <elem xmlns="newURI"><a/></elem>
+ </empty>
+
+ <!-- xmlns is not removed during the modifications -->
+ <empty xmlns="">
+ <elem/>
+ <elem xmlns="newURI"><a/></elem>
+ </empty>
+
+
+ <!-- tests from namespace spec -->
+ <x xmlns="http://www.w3.org" xmlns:n1="http://www.w3.org">
+ <good a="1" b="2"/>
+ <good a="1" n1:a="2"/>
+ </x>
<!--add element in the same scope-->
<s:bar xmlns:s="urn:schemas-xmlsoap-org:soap.v1"/>
@@ -20,6 +39,9 @@
<!--create element: _attr_ bound to _hi_, local declaration of xmlns:attr = boo-->
<attr:foo xmlns:attr="hi"/>
+
+<!--create element: with 2 xmlns-->
+<elem xmlns="namespace1"/>
<!--
1) noBooPrefixAttr had no prefix and bound to _boo_ URI (boo is not declared).
1.2 +21 -1 xml-xerces/java/tests/dom/serialize/input.xml
Index: input.xml
===================================================================
RCS file: /home/cvs/xml-xerces/java/tests/dom/serialize/input.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- input.xml 12 Jan 2002 00:11:49 -0000 1.1
+++ input.xml 19 Feb 2002 19:36:12 -0000 1.2
@@ -3,7 +3,27 @@
xmlns="default namespace"
xmlns:s='myschema/namespace'
xmlns:xsi='http://www.w3.org/1999/XMLSchema/instance'>
- <s:Body >
+ <s:Body>
<length>3</length>
</s:Body>
+
+ <!-- xmlns is removed during the modifications -->
+ <empty xmlns="">
+ <elem xmlns=""/>
+ <elem xmlns="newURI"><a/></elem>
+ </empty>
+
+ <!-- xmlns is not removed during the modifications -->
+ <empty xmlns="">
+ <elem/>
+ <elem xmlns="newURI"><a/></elem>
+ </empty>
+
+
+ <!-- tests from namespace spec -->
+ <x xmlns:n1="http://www.w3.org"
+ xmlns="http://www.w3.org" >
+ <good a="1" b="2" />
+ <good a="1" n1:a="2" />
+ </x>
</s:Envelope>
1.4 +32 -2 xml-xerces/java/tests/dom/serialize/TestNS.java
Index: TestNS.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/tests/dom/serialize/TestNS.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestNS.java 1 Feb 2002 17:34:01 -0000 1.3
+++ TestNS.java 19 Feb 2002 19:36:12 -0000 1.4
@@ -70,7 +70,7 @@
* the document using XMLSerializer.
*
* @author Elena Litani, IBM
- * @version $Id: TestNS.java,v 1.3 2002/02/01 17:34:01 elena Exp $
+ * @version $Id: TestNS.java,v 1.4 2002/02/19 19:36:12 elena Exp $
*/
public class TestNS {
public static void main( String[] argv) {
@@ -143,6 +143,17 @@
parser.parse( argv[i] );
Document core = parser.getDocument();
+
+ NodeList ls2 = core.getElementsByTagName("empty");
+ Node testElem = ls2.item(0);
+ // testing empty element
+ if (testElem !=null) {
+
+ NamedNodeMap testAttr = testElem.getAttributes();
+ testAttr.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns");
+ }
+
+
if (modify) {
System.out.println("Modifying document...");
@@ -158,6 +169,9 @@
System.out.println("Modifying information for the element: "+element.getNodeName());
}
+
+
+
// add element in same scope
element.appendChild(core.createComment("add element in the same scope"));
element.appendChild(core.createTextNode("\n"));
@@ -202,6 +216,22 @@
element.appendChild(core.createTextNode("\n\n"));
+
+ // add 2 xmlns attribute
+ element.appendChild(core.createComment("create element: with 2 xmlns"));
+ element.appendChild(core.createTextNode("\n"));
+ elm = core.createElementNS("namespace1","elem");
+ attr = core.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns");
+ attr.setValue("boo");
+ elm.setAttributeNode(attr);
+
+ attr = core.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns");
+ attr.setValue("world");
+ elm.setAttributeNode(attr);
+ element.appendChild(elm);
+ element.appendChild(core.createTextNode("\n\n"));
+
+
// work on attributes algorithm
element.appendChild(core.createComment("\n1) noBooPrefixAttr had no prefix and bound to _boo_ URI (boo is not declared)."+
"\n2) dummy attribute with null namespace"+
@@ -313,7 +343,7 @@
saxSerializer.endElement("myNamespace", "a", "foo:a");
saxSerializer.endDocument();
System.out.println("Serializing output to sax_output.xml...");
- */
+ */
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org