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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Little Help :))) (2)
-> + Xquery tag position (2)
-> - Can I connect to MonetDB/XQuer... (1)
-> + Is there a way to format a num... (2)
-> + Please help convert SQL query ... (3)
-> + Connect to SQL Server Express ... (3)
-> - Convert HTML to XML within C# ... (1)
-> + return different result based ... (7)
-> + Java Heap Space (2)
-> + XQuery Results export to multi... (3)
-> + NO RETURN (5)
-> + Part of a csv into a current X... (3)
-> + How to escape ampersand in xqu... (2)
-> + How to Convert CSV lines to in... (5)
-> + Data connection Stylus Studio ... (2)
-> + Nested XQuery FLOWRs with RDBM... (3)
-> + observing xquery at work (2)
-> + alternative for 'exists' (4)
-> + Xquery and webpages how? (2)
-> + Help with another DataDirect p... (5)
-- Previous [121-140] [141-160] [161-180] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.