Hi, 

I tested the use-case described below and replaced the standard
CompareDocuments class with our NodeMatcher class that we use in our
company. I came across a difference between the result document and the
"expected" result document that wasn't noticed by CompareDocuments: in
the city element of the XUpdated document the localname is "null"
because it is created with createElement(String tagName) and not with
createElementNS(String namespaceURI, String qualifiedName). However
because the city element doesn't have a namespace doesn't mean it is not
a DOM level 2 node (created with createElementNS()). 

One solution in RenameCommand could be to replace:

                    if (current.getNamespaceURI( )==null) {

with 

                    if (current.getLocalName( )==null) {
                // getLocalName( ) is a proper test for a level 2 DOM
Node

A solution could also be to always use createElementNS(String
namespaceURI, String qualifiedName) (with null for namespaceURI for
element without a namespace), this would mean XUpdate is no longer
compatible with DOM level 1

This issue comes back on several other places where elements AND
attributes are created.

X-Hive would gladly donate this NodeMatcher class which I'm sure is a
lot more extensive then the current CompareDocuments class and it also
integrated with JUnit.

greetings,

jeroen

-----------------
USE-CASE:

input:

<?xml version="1.0"?>
<addresses>
  <address name="Andreas">
    <town>New York</town>
  </address>
  <address name="Lars">
    <town>Los Angeles</town>
  </address>
</addresses>

update:

<lexus:modifications version="1.0"
xmlns:lexus="http://www.xmldb.org/xupdate";>
  <lexus:rename select="//address/town">city</lexus:rename>
</lexus:modifications>

result:

<?xml version="1.0"?>
<addresses>
  <address name="Andreas">
    <city>New York</city>
  </address>
  <address name="Lars">
    <city>Los Angeles</city>
  </address>
</addresses>
--

X-Hive Corporation
e-mail: [EMAIL PROTECTED]
phone: +31 10 7108622
http://www.x-hive.com
----------------------------------------------------------------------
Post a message:         mailto:[EMAIL PROTECTED]
Unsubscribe:            mailto:[EMAIL PROTECTED]
Contact administrator:  mailto:[EMAIL PROTECTED]
Read archived messages: http://archive.xmldb.org/
----------------------------------------------------------------------

Reply via email to