
Anonymous
Not applicable
2013-03-28
12:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
XPath - how to use position() in XMLInput
Hello folks,
i have come across this file that has no identifier for the <b>Item</b>:
i would like to get the output of this file normalised to:
where the value of item would be returned by the XPath expression position()
But i am failing to understand how the expression should be entered in the tFileInputXML
this is a similar question to:
https://community.talend.com/t5/Design-and-Development/XML-record-count/td-p/74328
and i would very much appreciate assistance with this.
regards
i have come across this file that has no identifier for the <b>Item</b>:
<Items>
<Item>
<Detail1>A</Detail1>
<Detail3>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
<Item>
<Detail2>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
...
</Items>
i would like to get the output of this file normalised to:
Item |Detail1 |Detail2 |Detail3 |Detail4
1 |A | |B |B
where the value of item would be returned by the XPath expression position()
But i am failing to understand how the expression should be entered in the tFileInputXML
this is a similar question to:
https://community.talend.com/t5/Design-and-Development/XML-record-count/td-p/74328
and i would very much appreciate assistance with this.
regards
228 Views
1 Reply

Anonymous
Not applicable
2013-03-28
02:25 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This shows an XPath that returns the sequence of the parent node.
http://blogs.msdn.com/b/asanto/archive/2004/09/08/226663.aspx
count(parent::*/preceding-sibling::*) + 1
However when run in 'Refresh Preview' or in a job the column is empty.
When the job is configured with 'Get Nodes' enabled on the tFileInputXML then the results show that the sequence is being calculated.
e.g. from a different dataset:
.-------------------+----------------------------------+--------.
| tLogRow_1 |
|=------------------+----------------------------------+-------=|
|key |value |entityid|
|=------------------+----------------------------------+-------=|
|key="jurisdiction" |value="GB" |1.0 |
|key="domicile" |value="UK" |1.0 |
How can the column I call 'entityid', computed from the earlier 'count...' XPath be accessed?
The first two columns of output show the full node value of their attribute, so could potentially be parsed.
http://blogs.msdn.com/b/asanto/archive/2004/09/08/226663.aspx
count(parent::*/preceding-sibling::*) + 1
However when run in 'Refresh Preview' or in a job the column is empty.
When the job is configured with 'Get Nodes' enabled on the tFileInputXML then the results show that the sequence is being calculated.
e.g. from a different dataset:
.-------------------+----------------------------------+--------.
| tLogRow_1 |
|=------------------+----------------------------------+-------=|
|key |value |entityid|
|=------------------+----------------------------------+-------=|
|key="jurisdiction" |value="GB" |1.0 |
|key="domicile" |value="UK" |1.0 |
How can the column I call 'entityid', computed from the earlier 'count...' XPath be accessed?
The first two columns of output show the full node value of their attribute, so could potentially be parsed.
228 Views
