Subjects
Home
VOTE Move XML Commons to Xerces
Commented: (XERCESJ 589) Bug with pattern restriction on long strings
: Xerces J 2 8 1 Release on Wednesday, September 13th
: Xerces J 2 9 0 Release on Wednesday, November 22nd
Commented: (XERCESJ 1066) Restriction+choice+substitutionGroup error
Commented: (XERCESJ 1178) Error getting prefix for an attribute with no n
Updated: (XERCESJ 1244) XMLSchemaValidator does not contribute element 's
Some consideration about the xerces DOM implementation
Updated: (XERCESJ 1066) Restriction+choice+substitutionGroup error
Commented: (XERCESJ 1227) Poor performance / OutOfMemoryError for sequenc
retain exception stack traces
Updated: (XERCESJ 1193) NPE or hang when parsing using the "continue afte
Future of NekoHTML
Commented: (XERCESJ 1203) NPE in XMLDTDProcessor
DOM Level 3 APIs for Xalan J and a new Xalan release (2 7 1)
: xml commons external 1 3 04 Release on Wednesday, November 22nd
Commented: (XERCESJ 1247) Incorrect location information on SAX when usin
XInclude exceptions how to mirror Xerces J functionality into Xerces C++?
First proposal on SoC project "Add support for the StAX (JSR 173) cursor API
: xml commons resolver 1 2 Release on Wednesday, November 22nd
Typo in RangeToken java Please check
Validator features
java lang ClassCastException when adopting Node
using the org apache xerces impl xs identity package
Updated: (XERCESJ 1257) buffer overflow in UTF8Reader for characters out
Problem with ref attributes and schema validation
Updated: (XERCESJ 122) XMLSchemaValidator does not contribute element 's d
Performance problem under load Xerces with Weblogic 9 x
remove ignored memory allocation
Commented: (XERCESJ 1177) SAXXMLStreamReader doesn 't always report namesp
Commented: (XERCESJ 977) Null pointer exception during DOM parsing
Commented: (XERCESJ 1197) Code cleanup for org apache xml serialize
Commented: (XERCESJ 1201) Initial contribution for StAX Event API
Updated: (XERCESJ 1061) Regex "$ " and "^ " characters treated as special c
Commented: (XERCESJ 1199) SAXXMLStreamReader should attempt to register a
Commented: (XERCESJ 1061) Regex "$ " and "^ " characters treated as special
Updated: (XERCESJ 589) Bug with pattern restriction on long strings
StackOverflow
xerces Range unnecessarily not garbage collectable if not detached
Updated: (XERCESJ 1178) Error getting prefix for an attribute with no nam
Bug in xs:redefine
Commented: (XERCESJ 1204) Can not set XMLEntityResolver for LSParser
Updated: (XERCESJ 1253) Prototype for SoC2007 project "Add support for th
Updated: (XERCESJ 1259) Add SteamFilter Function to SoC2007 project "Add
Assigned: (XERCESJ 444) SAXException thrown by EntityResolver is reported
Google Summer of Code 2007
Xerces J and XInclude relative path issue
Assigned: (XERCESJ 206) Stack overflow when using a schema validation
Commented: (XERCESJ 1215) Restrictions involving two levels of substituti
Closed: (XERCESJ 1203) NPE in XMLDTDProcessor
non overriding equals methoda
Resolved: (XERCESJ 1079) invalid value returned for TOTALDIGITS facet in
Xerces AS3 port
Updated: (XERCESJ 325) Regular Expression; Pattern "| " clause order de
Updated: (XERCESJ 1196) Javadoc generation fails on Java SE 5 0
Closed: (XERCESJ 1202) DTD validation on XIncluded documents when the sch
Created: (XERCESJ 1124) Nonspecific schema error message
a bug in xerces
Updated: (XERCESJ 1201) Initial contribution for StAX Event API
Closed: (XERCESJ 1254) Empty uris in targetNamespace attribute not report
Links
Home
Oracle database error code
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Same element append at multiple places in DOM

Same element append at multiple places in DOM

2003-09-29       - By Singh, Anoop
Reply:     1     2  

Hi All,
       I am trying to append an element ( I'm calling it common element
) at multiple places in the DOM hierarchy. But it seems
       DOM is not accepting the same element at multiple places. In the
output it always has only one common element.

       Here is some more detailed analysis what I was trying to do:-

   Document doc= new DocumentImpl();
   Element root = doc.createElement("set");    
   Element common = doc.createElement("common"); //This is common
element
   Element book2 = doc.createElement("book2");  
   Element book1 = doc.createElement("book1");  
   Element document1 = doc.createElement("document");      
   document1.appendChild( common ); //append common element under
document1
   book1.appendChild( common );     //append common element under book1
   book1.appendChild( document1 );
   root.appendChild( book1 );
   root.appendChild( book2 );                      
   doc.appendChild( root );  

OUTPUT is:-
<set><book1><common/><document/></book1><book2/></set>

common element is not getting appended to the document1
Is there any such restriction that same element can't be appended at
more than one place ?
I tried by cloning the common element and then appending under document1
, but still no luck.

Then I added one more common element in the end as:-
book2.appendChild( common );    

OUTPUT is:-
<set><book1><document/></book1><book2><common/></book2></set>

One interested thing I observed is that it always appends the common
element for the last appendChild() call only!!

Any help or any pointers in this regard will be greatly appreciated.

Thanks,
Anoop Singh



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=689432323-29092003>Hi
All,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=689432323-29092003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am trying
to append an element ( I'm calling&nbsp;it common element )&nbsp;at multiple
places in the DOM hierarchy. But it seems </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=689432323-29092003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DOM&nbsp;</SPAN></FONT><FONT face=Arial size=2><SPAN class=689432323-29092003
>is
not accepting the same element at multiple places. In the output it always has
only one common element.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=689432323-29092003>&nbsp;</SPAN></FONT><FONT face=Arial size=2><SPAN
class=689432323-29092003></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=689432323-29092003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Here is
some
more detailed analysis what I was trying to do:-</SPAN></FONT></DIV>
<DIV><FONT face=Courier size=2><SPAN
class=689432323-29092003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Courier size=2>&nbsp;&nbsp;&nbsp;&nbsp;Document doc= new
DocumentImpl();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Element root =
doc.createElement("set");&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;
Element
common = doc.createElement("common");<SPAN class=689432323-29092003> <FONT
face=Arial>//This is common
elemen</FONT>t</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;Element book2 =
doc.createElement("book2");&nbsp; <BR>&nbsp;&nbsp;&nbsp; Element book1 =
doc.createElement("book1");&nbsp; <BR>&nbsp;&nbsp;&nbsp; Element document1 =
doc.createElement("document");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=Courier><FONT size=2><STRONG>&nbsp;&nbsp;&nbsp;<SPAN
class=689432323-29092003> </SPAN></STRONG>document1.appendChild( common );<SPAN
class=689432323-29092003> <FONT face=Arial>//append <FONT
face=Courier>common</FONT> element under </FONT><FONT
face=Courier>document1</FONT></SPAN><BR>&nbsp;&nbsp;&nbsp; book1.appendChild(
common );<SPAN class=689432323-29092003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT
face=Arial>//append <FONT face=Courier>common</FONT> element under </FONT><FONT
face=Courier>book1<BR></FONT></SPAN>&nbsp;&nbsp;&nbsp; book1.appendChild(
document1 );<BR>&nbsp;&nbsp;&nbsp; root.appendChild( book1
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;root.appendChild( book2
);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;
&nbsp;&nbsp;doc.appendChild(
root );&nbsp; </FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>OUTPUT is:<SPAN
class=689432323-29092003>-</SPAN><BR><FONT
face=Courier>&nbsp;&lt;set&gt;&lt;book1&gt;&lt;common/&gt;&lt;document/&gt;&lt;
/book1&gt;&lt;book2/&gt;&lt;/set&gt;</FONT>&nbsp;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><FONT face=Courier><SPAN
class=689432323-29092003>c</SPAN>ommon</FONT> element is not getting appended
to
the <FONT face=Courier>document1</FONT> <BR>Is there any such restriction that
same element can't be appended at more than one place ? <BR>I tried by cloning
the <FONT face=Courier>common</FONT> element and then appending under <FONT
face=Courier>document1</FONT> , but still no luck.</FONT></FONT></DIV>
<DIV><FONT size=2></FONT><FONT size=2></FONT><FONT size=2></FONT><FONT
size=2></FONT><FONT size=2></FONT><BR><FONT face=Arial size=2>Then I added one
more&nbsp;<SPAN class=689432323-29092003><FONT face=Courier>common</FONT>
element</SPAN> in the end as<SPAN class=689432323-29092003>:-</SPAN><BR><FONT
face=Courier>book2.appendChild( common );</FONT>&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>OUTPUT is:<SPAN
class=689432323-29092003>-</SPAN><BR><FONT
face=Courier>&lt;set&gt;&lt;book1&gt;&lt;document/&gt;&lt;/book1&gt;&lt;book2
&gt;&lt;common/&gt;&lt;/book2&gt;&lt;/set&gt;</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>One interested thing I observed is that it always
appends the <FONT face=Courier>common</FONT> element for the last <FONT
face=Courier>appendChild()</FONT> call only!!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=689432323-29092003><FONT face=Arial size=2>Any help or any
pointers in this regard will be greatly appreciated.</FONT></SPAN></DIV><!--
Converted from text/rtf format -->
<P><FONT face=Arial><FONT color=#000080><FONT size=2><SPAN
class=689432323-29092003>Thanks</SPAN>,</FONT></FONT></FONT> <BR><FONT
face=Arial color=#ff9900 size=2>Anoop Singh</FONT>&nbsp;</P>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>