Problem with non mandatory elements

One Star

Problem with non mandatory elements

Hi,
I'm trying to load a complex (XSD about 4.5tsd lines) XML file into a database. Since the XML file is also pretty large the assistant for loading a XML file does not work. I can only use the operators tFileInputXML or tFileInputMSXML with the sax option. That's ok so far but I figured out that everytime an element is not present in the XML file, the whole schema is lost for that row. In case of tFileInputXML this means that I would have to implement at least one single operator for every non mandatory XML element and join the results later. In case of tFileInputMSXML this means that I would have to implement at least one single outputline for every non mandatory XML element and join the results later. Since there are a lot of non mandatory XML elements this is absolutely not applicable. Am I missing something or are these operators not designed for complex XML files?
thanks in advance, chris
btw: There is a problem with my registration, I'm logged in to talend.com but not to talendforge.org. I can log in (talend.com) but back on talendforge it says that I'm not logged in but my username is used here.
One Star

Re: Problem with non mandatory elements

If an optional Element or Attribute is missing in your input XML file, then the output schema would contain null values and all the mandatory fields must be present.
The only case when the schema could be lost - does not result in a flow output row, will happen when your loop xpath contains one or more of the optional elements.
This behaviour is absolutely correct, if there is nothing to loop, then no output!
How can you read other Mandatory Elements?
Option 1 is to define find another LOOP XPATH which would be based on the mandatory elements only.
Option 2 split your main XML into two or more smaller XML subsets and set LOOP XPATH for each individually. You can do the split with tFileInputXML or tXMLMap.
Optino 3 ...there is always a way Smiley Happy
Example for option 2
Let's say you expect XML like this:
<Customer>
<Name>
<FirstName>Fred</FirstName>
<LastName>Flintstone</LastName>
</Name>
<Addresses>
<Address>
<POSTCODE>XYZ</POSTCODE>
</Address>
<Address>
<POSTCODE>123</POSTCODE>
</Address>
</Addresses>
</Customer>
if you had your loop xpath set as "/Customer/Addresses/Address" you would be not able to record any Customers that have no Address recorded in the XML.
Basically you would be getting no output from this kind of XML
<Customer>
<Name>
<FirstName>Fred</FirstName>
<LastName>Flintstone</LastName>
</Name>
</Customer>
But if you split your main XML into two and process first one with LOOP XPATH = "/Name" and second with "/Addresses/Address" you would still be getting a result from the first one even if the second one has no output.

To your issue with login have a look at this http://www.talendforge.org/forum/viewtopic.php?id=27937
I had the same issue and it helped when I changed the password.