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.
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.
Created attachment 62412 [details] NamespaceA.xsd
Created attachment 62413 [details] NamespaceB.xsd (This imports NamespaceA.xsd)
Created attachment 62414 [details] XML generated from Eclipse.
Created attachment 62415 [details] XML generated from Netbeans (Incorrect namespace for AnElementOfA)
This is also affecting the XPath that the XSLT Service (visual mapper) generates for reading the element.
Updated the summary.
*** Issue 137418 has been marked as a duplicate of this issue. ***
Fixed
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.
Tony, I tried it and it works for me. Can you check the log file and see if you see anything there?
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
Unable to reproduce on mac. Tony will keep an eye out for this bug and reopen if needed
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.
Created attachment 63772 [details] Log file from failed correct generation on linux
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.
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.
The cause is a mystery. For instance, on Mac, why is there different behavior whether launching the IDE from Dock Icon or command line?
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...
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)
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.
Created attachment 64116 [details] Demonstrates the "ref" issue in XPath generation. check the XSLT file for namespace in the XPath for aPerson v1
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
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
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)
Issue 139967 reported for the XPath/XSLT defect.
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)
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!
the fix has been pushed into release61_fixes repository: http://hg.netbeans.org/release61_fixes/rev/5f678e034a07