Hi
Is it possible to have xmlxqueryextractor to read from the source of a Sampler.
My issue is the source XML file has multiple records therefore I only wish to process them singularly from a sampler of 1st...
Cheers
Hi
Is it possible to have xmlxqueryextractor to read from the source of a Sampler.
My issue is the source XML file has multiple records therefore I only wish to process them singularly from a sampler of 1st...
Cheers
I suppose this question is derived from "XMLFragmenter - Exclude Attributes.
I cannot understand correctly what you mean with "the source XML file has multiple records", since usually the terminology "record" is not used in XML operations.
If you are looking for an XQuery syntax to extract an element at a specific position within a sequence of sub elements belonging to an identical parent element, the following example might help you.
Assuming that the source XML looks like this,
<?xml version="1.0"?>
<parent>
<child>
<attribute>11</attribute>
<attribute>12</attribute>
<attribute>13</attribute>
</child>
<child>
<attribute>21</attribute>
<attribute>22</attribute>
<attribute>23</attribute>
</child>
<child>
<attribute>31</attribute>
<attribute>32</attribute>
<attribute>33</attribute>
</child>
</parent>
this XQuery expression extracts the values of <attribute> elements under the first <child> element belonging to the <parent> element.
for $a in //parent/child&1]/attribute
return $a/text()
That is, n<position>] following to an element name in an XML path works to specify the position of an element to be extracted. Note that the position of an element should be specified with 1-based sequential number, unlike FME uses 0-based number as the index for list elements.
If you set the expression to the XQuery Expression parameter in an XMLXQueryExtractor, and set "List Attribute" to the Return Value parameter, the output feature would have this list attribute.
Attribute(encoded: utf-8): `_results{0}' has value `11'
Attribute(encoded: utf-8): `_results{1}' has value `12'
Attribute(encoded: utf-8): `_results{2}' has value `13'
If the example above couldn't help you, please paste an XML example (a simplified but valid XML fragment) and explain what you need to get from the XML.
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
sample-xml-reports-report-id.xml
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
I guess that the reports element contains multiple child elements (called report?) and each child element have an attribute called report_id. Is it right?
If so, and if you need to fragment the reports element into each child element as individual features, the XMLFragmenter might help you.
Input? A feature has a single <reports> element containing multiple <report> element.
<reports>
<report report_id="1" />
<report report_id="2" />
<report report_id="3" />
</reports>
Desired result? Each feature has a single <report> element.
<report report_id="1" />
<report report_id="2" />
<report report_id="3" />
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
Hi takashi, I've attached a copy of the workspace which may be easier than me attempting to explain.
Public key will be messaged across.
Many thanks again for your assistance.
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
Then, what do you want to get from them?
Can you please explain using a simplified example, as I used above? It's hard to find your interest parts from the full XML document. Please extract only important parts to explain the question.
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
Attached Excel Doc is what I'm hopinh to acheive from the XML ...
xml-goals.xlsx
Many thanks.
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
@takashi
Hello takashi
Thank you for your time.Attached is a typical example of an XML document.The xml document has an element for "reports" which contain multiple unique "report_id".Each "report_id" contains a Service Request for either "SBC_MISSED_BIN", "SBC_ASSISTED", "SBC_COMPLAINTS" or "SBC_SPECIALS"If your script below could process each "report_id" in turn this may resolve the issue?
for $q in //questionnaires/que_anslet $k := xs:string($q/@que_key) where $k ne '' return ( fme:set-attribute($k||'_ANS', $q/ans/text()),fme:set-attribute($k||'_ANS_VALUE', $q/ans_value/text()) )
Thank you again for your assistance.
Early signs are looking promising.
Many thanks for your support and patience.
Much appreciated