XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Peter RobertSubject: Search a sequence of siblings (for each ??) within a delimited range
Author: Peter Robert
Date: 08 Jul 2009 11:12 AM
Hi,

I need to treat the result of flat file conversion, which results in a flat XML structure.

Now, I want to grab each occurence of 3 elements within a certain delimited range (between each LETTERHEAD, as this is the delimiter).

As of now, I'm working with "following-sibling", but I'm stuck somewhat:
for $Service_dig in root/LETTERHEAD/following-sibling::*[local-name()="DSQ"][1]
let $DSD := $Service_dig/following-sibling::*[local-name()="DSD"][1]
let $DSR := $Service_dig/following-sibling::*[local-name()="DSR"][1]
return
<SERVICE_DIG>
{$DSD/SERVICE_NAME}
{$Service_dig/QUANTITY}
{$DSR/GROSSAMOUNT}
</SERVICE_DIG>

If I set the sibling position to [1], I only get the first element, although there are several (1 - x) within a letter (LETTERHEAD to next LETTERHEAD)

If I remove the sibling position, I get every DSQ sequence of the whole file.

How can I tell it to take only those until the next LETTERHEAD occurence?

Thanks

Peter

Postnext
Ivan PedruzziSubject: Search a sequence of siblings (for each ??) within a delimited range
Author: Ivan Pedruzzi
Date: 08 Jul 2009 02:03 PM
Peter,

You should be able to use a more efficient form like the following, but I am not sure about the semantic. Can you share a sample of the XML input you are trying to process

for $Service_dig in root/LETTERHEAD/following-sibling::DSQ[1]
let $DSD := ($Service_dig/following-sibling::DSD)[1]
let $DSR := ($Service_dig/following-sibling::DSR)[1]

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
Peter RobertSubject: Search a sequence of siblings (for each ??) within a delimited range
Author: Peter Robert
Date: 09 Jul 2009 03:18 AM
Originally Posted: 09 Jul 2009 03:17 AM
Hi Ivan,

Sure, here's a snippet of the XML...
...
<LETTERHEAD>
<field>LH</field>
<Typ>DAB</Typ>
<Kundennummer>101160901</Kundennummer>
<Suffix>0</Suffix>
<Country>D</Country>
</LETTERHEAD>
<N1>
<field>N1</field>
<N1>Herr</N1>
</N1>
...
<ANQ>
<field>LD#ANQNM</field>
<QUANTITY>00001</QUANTITY>
</ANQ>
<ANS>
<field>LD#ANSNM</field>
<GROSSAMOUNT>E+000000016,39</GROSSAMOUNT>
</ANS>
<DSQ>
<field>LD#DSQNM</field>
<QUANTITY>1</QUANTITY>
</DSQ>
<DFD>
<field>LD#DFDNM</field>
<SERVICE_NAME>Digital TV FREE</SERVICE_NAME>
</DFD>
<DSR>
<field>LD#DSRNM</field>
<GROSSAMOUNT>E+000000000,00</GROSSAMOUNT>
</DSR>
<DSQ>
<field>LD#DSQNM</field>
<QUANTITY>1</QUANTITY>
</DSQ>
<DFD>
<field>LD#DFDNM</field>
<SERVICE_NAME>Music Choice</SERVICE_NAME>
</DFD>
<DSR>
<field>LD#DSRNM</field>
<GROSSAMOUNT>E+000000000,00</GROSSAMOUNT>
</DSR>
<DSQ>
<field>LD#DSQNM</field>
<QUANTITY>1</QUANTITY>
</DSQ>
<DFD>
<field>LD#DFDNM</field>
<SERVICE_NAME>Digital-Receiver (Miete)</SERVICE_NAME>
</DFD>
<DSR>
<field>LD#DSRNM</field>
<GROSSAMOUNT>E+000000000,00</GROSSAMOUNT>
</DSR>
<DSQ>
<field>LD#DSQNM</field>
<QUANTITY>1</QUANTITY>
</DSQ>
<DSD>
<field>LD#DSDST</field>
<SERVICE_NAME>Digital TV BASIC (monatlich)</SERVICE_NAME>
</DSD>
<DSR>
<field>LD#DSRNM</field>
<GROSSAMOUNT>E+000000000,00</GROSSAMOUNT>
</DSR>
<DSQ>
<field>LD#DSQNM</field>
<QUANTITY>1</QUANTITY>
</DSQ>
<DSD>
<field>LD#DSDST</field>
<SERVICE_NAME>Digital TV PLUS</SERVICE_NAME>
</DSD>
<DSR>
<field>LD#DSRNM</field>
<GROSSAMOUNT>E+000000007,90</GROSSAMOUNT>
</DSR>
<OTQ>
<field>LD#OTQNM</field>
<QUANTITY>00001</QUANTITY>
</OTQ>
<OTD>
<field>LD#OTDST</field>
<SERVICE_NAME>Digital-Receiver</SERVICE_NAME>
</OTD>
<OTC>
....
<LT>
<field>LT</field>
<LT>000066</LT>
</LT>
<LETTERHEAD>
...
</LETTERHEAD>

Maybe the <LT> could help as well, this is the LETTERTRAILER and marks the end of a letter...

Peter

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.