tAdvancedFileOuputXML not able to use namespace prefix for root elemen

One Star

tAdvancedFileOuputXML not able to use namespace prefix for root elemen

Good Afternoon,
I hope you can help me with a problem on XML file generation.
Please see attached for screenshots of the jobs and XML tree setup.
I am using tAdvancedFileOutputXML to create an XML file that uses a namespace called "scf".
I have been able to get the file to generate (jobs complete successfully) but I can only get the sub-elements to display with the namespace prefix. If I add the namespace pref to the root element i.e. <scfSmiley SurprisedpenItems> rather than <OpenItems> I encounter the following error:
"Exception in component tAdvancedFileOutputXML_1
java.lang.NullPointerException
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.tSybaseInput_3Process(SCF_OI_Extractor_v2.java:4418)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.tWarn_4Process(SCF_OI_Extractor_v2.java:2473)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.runJobInTOS(SCF_OI_Extractor_v2.java:7986)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.main(SCF_OI_Extractor_v2.java:7800)"
If I leave the XML tree root element without a namespace prefix my tXSDValidator job fails as the namespace is required in my xsd schema.
Can you please give me advice on a workaround or if I am using the jobs/tree incorrectly?
Thanks for your help!
Best regards,
Fabrice
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

hi,
try by specifying hour "xmlns:scf" like an attribute and give it a default value !
Here a little similar example with svg and 2 differents namespaces :
the result :
<?xml version="1.0" encoding="ISO-8859-15"?>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
baseProfile="full"
xmlns:xlink="http://www.w3.org/1999/xlink">
<svg:rect x="70" y="45" height="75" width="67" fill="red"/>
<svg:script xlink:href="script.js"/>
</svg:svg>

hope it helps
regard
laurent
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

Thanks for your response Smiley Happy
I am running Talend 4.01 (r41260-20100429-0544).
I tried your suggestion before too but it results in a different error. It seems to indicate that Talend cannot resolve the namespace when creating the XML file.
In my previous configuration it recognises the namespace but doesn't set the prefix on the root element.
If your test scenario works then it may be ordering of the attributes.
"Exception in component tAdvancedFileOutputXML_1
org.dom4j.XPathException: Exception occurred evaluting XPath: /scfSmiley SurprisedpenItems/scf:buyer. Exception: XPath expression uses unbound namespace prefix scf
at org.dom4j.xpath.DefaultXPath.handleJaxenException(DefaultXPath.java:374)
at org.dom4j.xpath.DefaultXPath.selectSingleNode(DefaultXPath.java:173)
at org.dom4j.tree.AbstractNode.selectSingleNode(AbstractNode.java:185)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.tSybaseInput_3Process(SCF_OI_Extractor_v2.java:4401)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.tWarn_4Process(SCF_OI_Extractor_v2.java:2473)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.runJobInTOS(SCF_OI_Extractor_v2.java:7983)
at ing_buyer_import.scf_oi_extractor_v2_0_1.SCF_OI_Extractor_v2.main(SCF_OI_Extractor_v2.java:7797)!"
Thanks
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

extra screenshots
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

Hey Symond,
Even I'm facing the same problem.
My XML looses its attributes and namespaces.
I used tAdvancedFileOutputXML Component to generate XML.
If you have the solution, please share.
Thanks & Regards,
Priya
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

Hey Symond,
Even I'm facing the same problem.
My XML looses its attributes and namespaces.
I used tAdvancedFileOutputXML Component to generate XML.
If you have the solution, please share.
Thanks & Regards,
Priya

please see attached for setup that worked for me
namespace was added to the schema with its value hardcoded as a default
not great but it worked for me
One Star

Re: tAdvancedFileOuputXML not able to use namespace prefix for root elemen

Hey Symond,
Thanks for reply.
Priya