This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 136560 - incorrect XML generation for elements of other namespaces
Summary: incorrect XML generation for elements of other namespaces
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Schema Tools (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Sonali Kochar
URL:
Keywords:
: 137418 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-06-05 15:32 UTC by svr_76
Modified: 2009-03-26 15:28 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NamespaceA.xsd (537 bytes, text/xml)
2008-06-05 15:33 UTC, svr_76
Details
NamespaceB.xsd (This imports NamespaceA.xsd) (621 bytes, text/xml)
2008-06-05 15:34 UTC, svr_76
Details
XML generated from Eclipse. (389 bytes, text/xml)
2008-06-05 15:34 UTC, svr_76
Details
XML generated from Netbeans (Incorrect namespace for AnElementOfA) (375 bytes, text/xml)
2008-06-05 15:35 UTC, svr_76
Details
Log file from failed correct generation on linux (54.78 KB, text/plain)
2008-07-01 19:05 UTC, tonybeckham
Details
Demonstrates the "ref" issue in XPath generation. check the XSLT file for namespace in the XPath for aPerson v1 (11.28 KB, application/x-compressed)
2008-07-08 23:19 UTC, svr_76
Details

Note You need to log in before you can comment on or make changes to this bug.
Description svr_76 2008-06-05 15:32:07 UTC
Netbeans is generating inccorect sample XML (based off a xsd). If an element is declared using "ref" attribute, where 
the ref points to a global element defined in a different Namespace, Netbeans still generates the element in the same 
namespace.

The sample XML generate by Netbeans differs from the sample XML generated from Eclipse (and it also differs from the 
XML generated by JAXB RI). The XML from JAXB and Eclipse are similar and consistent with the expected result

Attached schemas and sample XML point out the different. Check the namespace/prefix of AnElementOfA occuring in both 
the XMLs.
Comment 1 svr_76 2008-06-05 15:33:22 UTC
Created attachment 62412 [details]
NamespaceA.xsd
Comment 2 svr_76 2008-06-05 15:34:05 UTC
Created attachment 62413 [details]
NamespaceB.xsd (This imports NamespaceA.xsd)
Comment 3 svr_76 2008-06-05 15:34:51 UTC
Created attachment 62414 [details]
XML generated from Eclipse.
Comment 4 svr_76 2008-06-05 15:35:27 UTC
Created attachment 62415 [details]
XML generated from Netbeans (Incorrect namespace for AnElementOfA)
Comment 5 svr_76 2008-06-09 02:27:47 UTC
This is also affecting the XPath that the XSLT Service (visual mapper) generates for reading the element.
Comment 6 Samaresh Panda 2008-06-17 13:28:44 UTC
Updated the summary.
Comment 7 Samaresh Panda 2008-06-17 13:29:38 UTC
*** Issue 137418 has been marked as a duplicate of this issue. ***
Comment 8 Sonali Kochar 2008-06-23 15:36:18 UTC
Fixed
Comment 9 tonybeckham 2008-06-26 18:47:39 UTC
When I generate the sample xml for NamespaceB the referenced element is now of another namespace but that namespace is
not declared in the xml file.  

<ns0:AnElementOfNamespaceB  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
   xmlns:ns0='NamespaceB'
   xsi:schemaLocation='NamespaceB NamespaceB.xsd'>
        <ns0:myNS></ns0:myNS>
        <ns1:AnElementOfNamespaceA>
                <ns1:myNS></ns1:myNS>
            </ns1:AnElementOfNamespaceA>

</ns0:AnElementOfNamespaceB>

*shouldn't there be a xmlns:ns1='NamespaceA' in there?  At least that is how the eclipse version is.
Comment 10 Sonali Kochar 2008-06-27 04:29:09 UTC
Tony,

I tried it and it works for me. Can you check the log file and see if you see anything there?
Comment 11 tonybeckham 2008-06-27 22:23:44 UTC
I see it working on Windows XP, but on Mac and Linux it doesn't.  The output is the same as I pasted in desc 10.  No
namespace declaration for ns:1
Comment 12 Sonali Kochar 2008-07-01 05:33:28 UTC
Unable to reproduce on mac. Tony will keep an eye out for this bug and reopen if needed
Comment 13 tonybeckham 2008-07-01 19:03:58 UTC
It works on Mac but still not on linux.

System Info:
Product Version: NetBeans IDE Dev (Build 200807010102)
Java: 1.6.0_06; Java HotSpot(TM) Client VM 10.0-b22
System: Linux version 2.6.24-19-generic running on i386; UTF-8; en_US (nb)

I will attach messages.log file from running IDE with the patch.As you can see, there is a FileNotFoundException in the log.
Comment 14 tonybeckham 2008-07-01 19:05:33 UTC
Created attachment 63772 [details]
Log file from failed correct generation on linux
Comment 15 tonybeckham 2008-07-02 21:29:15 UTC
I found that on Mac the correct generation was happening but other times not.  It turns out that the incorrect
generation occurs when you start the IDE from the command line and not via the doc icon.  Starting from the icon
generation works on mac.  Still on linux no matter what method used to open the IDE the generated document still lacks
ns1 (in this case) declaration.  
Comment 16 svr_76 2008-07-02 21:35:48 UTC
IS the difference in behaviour of XML related to the JDK using the default XML parser on that system? 

e.g. On Linux (Ubuntu) you can install a deb package for XML parser (this could be Xerces 2.7?) but eventually
when netbeans schema model uses the parser etc to read xsd document or build xpath, it might be using functionality 
provided through the javax.xml.jaxp package. This package will rely on system property to use the default parser which
may or may not contribute to this problem?

Is it possible to rule out that the difference in behaviour across these platform exists even when netbeans (or the 
system properties) points to the same XML parser?

Just my thoughts.
Comment 17 tonybeckham 2008-07-08 22:10:07 UTC
The cause is a mystery.  For instance, on Mac, why is there different behavior whether launching the IDE from Dock Icon
or command line?
Comment 18 svr_76 2008-07-08 22:29:46 UTC
I am not familiar with Mac (apart from knowing its some variant of unix (headless root?) etc.
Is the difference in Mac when launched from icon and when launched from command because of the all the environment 
variables that get initialized/available in command prompt mode? I have not used it at all...so i could be completely 
wrong... 
Comment 19 tonybeckham 2008-07-08 22:57:35 UTC
Solaris has the same behavior as Mac.  Launched from Icon is correct, launched from terminal missing namespace
declaration for ns1.

Product Version: NetBeans IDE Dev (Build 200807080009)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b14
System: SunOS version 5.11 running on x86; UTF-8; en_US (nb)
Comment 20 svr_76 2008-07-08 23:17:16 UTC
I installed the 6.5M1 version and the XML generation works correct (on windows). However, the problem still exits when 
you try to create a XSLT module and use the visual mapper. The visual mappers generates XPath for the mapping between 
two schemas. and when u try to map a element defined using "ref" attribute the XPath does not use the namespace where 
the element is defined. Rather it takes the namespace where the element is being referenced.

I am attaching a ZIP of the XSLTModule I tested. The setup is similar. 

Two schemas Person & Party. Party "refers" to an global element defined in Person schema. (both these are in namespace 
v1. 

I created another set of the same schemas but with namespace v2. i.e. PArty in v2 namespace refering to person in v2 
namespace.

With this setup, I create XML document for PArty schema and they correctly generated Person with the right namespace.

However, when u create a transformation service (and a XSLT file) the XPath for person is wrong.

e.g. in V1 schema the xpath for person should be
         "/v1ns0:aParty/v1ns1:aPerson" where v1ns1 correctly reflects the "Ref" namespace.
  instead it generates          "/v1ns0:aParty/v1ns0:aPerson" pointing to namespace of party instead of person.

I think the XSLT,XPath or mapper stuff also needs to be updated to corectly use the ref attribute.
Comment 21 svr_76 2008-07-08 23:17:51 UTC
I installed the 6.5M1 version and the XML generation works correct (on windows). However, the problem still exits when 
you try to create a XSLT module and use the visual mapper. The visual mappers generates XPath for the mapping between 
two schemas. and when u try to map a element defined using "ref" attribute the XPath does not use the namespace where 
the element is defined. Rather it takes the namespace where the element is being referenced.

I am attaching a ZIP of the XSLTModule I tested. The setup is similar. 

Two schemas Person & Party. Party "refers" to an global element defined in Person schema. (both these are in namespace 
v1. 

I created another set of the same schemas but with namespace v2. i.e. PArty in v2 namespace refering to person in v2 
namespace.

With this setup, I create XML document for PArty schema and they correctly generated Person with the right namespace.

However, when u create a transformation service (and a XSLT file) the XPath for person is wrong.

e.g. in V1 schema the xpath for person should be
         "/v1ns0:aParty/v1ns1:aPerson" where v1ns1 correctly reflects the "Ref" namespace.
  instead it generates          "/v1ns0:aParty/v1ns0:aPerson" pointing to namespace of party instead of person.

I think the XSLT,XPath or mapper stuff also needs to be updated to corectly use the ref attribute.
Comment 22 svr_76 2008-07-08 23:19:40 UTC
Created attachment 64116 [details]
Demonstrates the "ref" issue in XPath generation. check the XSLT file for namespace in the XPath for aPerson v1
Comment 23 Sonali Kochar 2008-07-14 22:42:20 UTC
Fixed
details: http://hg.netbeans.org/main?cmd=changeset;node=c0c1567d982e

This changeset only fixes the incorrect xml generation on linux/mac boxes.
Please file a separate bug for XSLT/XPath

Comment 24 Quality Engineering 2008-07-17 04:45:28 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #324 build
Changeset: http://hg.netbeans.org/main/rev/c0c1567d982e
User: sonali@netbeans.org
Log: fix for #136560 incorrect XML generation for elements of other namespaces
Comment 25 tonybeckham 2008-07-17 20:23:11 UTC
Fix for generation verified.

As stated please file a separate issue for XSLT/XPath.


Product Version: NetBeans IDE Dev (Build 200807170007)
Java: 1.6.0_05; Java HotSpot(TM) 64-Bit Server VM 1.6.0_05-b13-52
System: Mac OS X version 10.5.4 running on x86_64; MacRoman; en_US (nb)
Comment 26 svr_76 2008-07-17 20:59:34 UTC
Issue 139967 reported for the XPath/XSLT defect.
Comment 27 tonybeckham 2008-07-18 02:58:44 UTC
Verified

Product Version: NetBeans IDE Dev (Build 200807170007)
Java: 1.6.0_05; Java HotSpot(TM) 64-Bit Server VM 1.6.0_05-b13-52
System: Mac OS X version 10.5.4 running on x86_64; MacRoman; en_US (nb)
Comment 28 pslechta 2009-01-28 11:02:39 UTC
Sonali, could you please provide all change sets that are required for this fix? We (sustaining) need it to be able to
port this fix into NB 6.1 patch. This problem was escalated by the customer.

Thanks you for your help in advance!
Comment 29 rbalada 2009-03-26 15:28:15 UTC
the fix has been pushed into release61_fixes repository:

http://hg.netbeans.org/release61_fixes/rev/5f678e034a07