One Star

[resolved] Error trying to read an XML file with NameSpaces

I'm trying to use a tFileInputXML component to read an XML file. The XML file contains namespaces which seems to cause errors trying to read the XML. Sample xml below. If I remove the namespaces, I'm able to read the file. Is there something I need to do differently when an XML file contains namespaces?
<?xml version="1.0" encoding="utf-8"?>
<ns0Smiley SurprisednRampMessageRequest xmlns:ns0="urn:xxxSmiley SurprisednRampMessageRequest:v1.0">
  <ns0Smiley FrustratedourceSystemName>xxx</ns0Smiley FrustratedourceSystemName>
  <ns0:MessageType>Exchange Rates</ns0:MessageType>
  <ns0:MessageTypeVersion>1.0</ns0:MessageTypeVersion>
  <ns0Smiley FrustratedourceMessageId>abc123</ns0Smiley FrustratedourceMessageId>
  <ns0Smiley FrustratedourceSentDatetime>2014-01-10T05:00:00</ns0Smiley FrustratedourceSentDatetime>
  <ns0Smiley Tongueayload>
    <ns0:ExchangeRateData xmlns:ns0="">
      <ns0:ExchangeRates>
        <ns0Smiley Very Happyate>2012-05-17</ns0Smiley Very Happyate>
        <ns0Smiley FrustratedellRate>4.670057</ns0Smiley FrustratedellRate>
        <ns0:BuyRate>4.670057</ns0:BuyRate>
        <ns0:MeanRate>4.670057</ns0:MeanRate>
        <ns0:Checksum>14.010171</ns0:Checksum>
        <ns0:CurrencyCode>AED</ns0:CurrencyCode>
      </ns0:ExchangeRates>
      <ns0:ExchangeRates>
        <ns0Smiley Very Happyate>2012-05-17</ns0Smiley Very Happyate>
        <ns0Smiley FrustratedellRate>2.275906</ns0Smiley FrustratedellRate>
        <ns0:BuyRate>2.275906</ns0:BuyRate>
        <ns0:MeanRate>2.275906</ns0:MeanRate>
        <ns0:Checksum>6.827718</ns0:Checksum>
        <ns0:CurrencyCode>ANG</ns0:CurrencyCode>
      </ns0:ExchangeRates>
    </ns0:ExchangeRateData>
  </ns0Smiley Tongueayload>
</ns0Smiley SurprisednRampMessageRequest>
9 REPLIES
Moderator

Re: [resolved] Error trying to read an XML file with NameSpaces

Hi,
Have you tried option "Ignore the namespaces" in Advanced settings of tfileinputxml?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Error trying to read an XML file with NameSpaces

I wanted to see if I could get it to work without the "Ignore the namespaces" option. I would think it should work without the option selected. Should it work without the option selected?
Moderator

Re: [resolved] Error trying to read an XML file with NameSpaces

Hi,
Currently, tFileInputXML can't be used to extract namespace value.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: [resolved] Error trying to read an XML file with NameSpaces

hi all,
And it seems that your file doesn't respect standard xml namespace.
Error on line 9 of document file:/C:/Users/lraulier/Documents/forum/readNamespace.xml: The value of the attribute "prefix="xmlns",localpart="ns0",rawname="xmlns:ns0"" is invalid. Prefixed namespace bindings may not be empty.

regards
laurent
One Star

Re: [resolved] Error trying to read an XML file with NameSpaces

That was just a cut/paste error, the actual xml has a valid namespace, thanks
Seventeen Stars

Re: [resolved] Error trying to read an XML file with NameSpaces

put as resolved if it's ok for you Smiley Wink
thanks 
regards
laurent
Seven Stars

Re: [resolved] Error trying to read an XML file with NameSpaces

Is there any example online with the "Ignore namespaces" option checked?
Seventeen Stars

Re: [resolved] Error trying to read an XML file with NameSpaces

hi,
it's in the doc from talend help ... just a check box :
https://help.talend.com/search/all?query=tFileInputXML&content-lang=en
regards
laurent
Seven Stars

Re: [resolved] Error trying to read an XML file with NameSpaces

Thanks for the link but I have already seen it.
The purpose behind asking for an example was that my situation differs a wee bit.
I am reading an XML file using tFileInputXML and then mapping its elements to database columns through tXMLMap component.
Now I am curious to know if in the tXMLMap where I define XML document structure by using "Import from File", do I keep the schema definitions along with their prefixes and also maintain the tag names with the namespace prefixes or do I remove them?