how to use tXMLMap with elements with variable number of occurrency
Hello, I am learning how to use the tXMLMap component and as an exercise I am trying to figure out a way to use tXMLMap to create a job that can read through an XML file and produce an exact replica of the same file.
The peculiar thing of this XML file is that within an element there are two compulsory elements (name and surname), an optional element (credit card number), and a list of transactions (outcomes and incomes) that can have any number of occurrencies.
The schema and a sample xml file compliant to the schema follow:
-------------------- BankAccount.xsd --------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:element name="account">
<xs:complexType>
<xs:sequence>
<xs:element name="ownerSurname" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="ownerName" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="creditCard" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="outcome" type="xs:decimal" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="income" type="xs:decimal" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-------------------------------------accounts.xml -----------------------------------------------
<collection>
<account>
<ownerSurname>Smith</ownerSurname>
<ownerName>John</ownerName>
<creditCard>xxxx-xxxx-xxxx-xxxx</creditCard>
<outcome>120.0</outcome>
<outcome>135.0</outcome>
<outcome>20.0</outcome>
<income>1120.0</income>
<income>35.0</income>
</account>
<account>
<ownerSurname>Brown</ownerSurname>
<ownerName>James</ownerName>
<outcome>1120.99</outcome>
<income>11.01</income>
<income>3.01</income>
</account>
<account>
<ownerSurname>White</ownerSurname>
<ownerName>James</ownerName>
<outcome>1</outcome>
<outcome>2</outcome>
<income>3</income>
</account>
</collection>
-------------------------------------------------------------------------------------------------
No matter the fact I read through user guide and components guide, I can't achieve this result. I think it's not rocket science and I really hope I am just missing something.
Can you provide me with a link to any example, or the actual solution?
If otherwise it's not possible at all, please tell me so.
Hello! I was having a simliar problem and couldnt find any result, so I thought I could post my solution here.
My Problem: I had to replace certain strings as value of an element in a xml-file.
Solution: Use XSLT "transform.xsl" to first copy the whole document and in a 2. step replace the strings which are stored in the XML "replace.xml" (previously created with tAdvancedFileOutputXML)
Contents of my files:
-----------------------------
replace xml:
<?xml version="1.0" encoding="ISO-8859-15"?>
<list>
<sic sic="old-text1">new-text1</sic>
<sic sic="old-text2">new-text2</sic>
</list>
-----------------------------
transform.xsl (still needs some improvement, currently replaces whole element and not just the value of it)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl
utput omit-xml-declaration="no" indent="no" />
Hello, Talend Can some one explain me how i can connect to tRowGenerator to tXMLMap and i want to show that output in the tAdvancedFileoutputXML. please reply me ASAP. Thank you.