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)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-> + How to substitute element or t... (2)
-> + Xalan support in x16? (2)
-> + The context item for axis step... (5)
-> - ASP to XSL (1)
-> + xsl report, with xml feed, SVG... (7)
-> + XSLT code to transform CSV typ... (2)
-> + Make xstl file working in brow... (4)
-> + identity template, result-docu... (6)
-> - identity template and xsl:resu... (1)
-> + java.lang.RuntimeException: Er... (5)
-> + How to check matching parenthe... (2)
-> - Error only on using xalan:eval... (1)
-> + XSLT not displaying SOAP respo... (2)
-> + How do i delete the node from ... (2)
-> + How to break xslt lines to mak... (4)
-> - Marge node using attribute val... (1)
-> - Replce utf to unicode using xs... (1)
-> - getting different instances of... (1)
-> + XML to Flat (4)
-> + non breaking space   in e... (2)
-> - How can i attach a empty names... (1)
-> + Cannot find a matching 1-argum... (7)
-> - get value from different docum... (1)
-> + How can I change the XML heade... (2)
-> + Stylus Studio and Datapower (9)
-> + Generate XML form a XSD (2)
-> + There is no way to run xslt tr... (3)
-> + XML-Source NS is copied into t... (3)
-> + new guy attempting xslt (2)
-> + XML 2011 question (7)
-> + Manipulating XML with external... (2)
-> + removing duplicates from xml w... (8)
-> + Wnat to use presence of tag t... (2)
-> + modifing Andrew Welch's csv 2 ... (5)
-> + Can't use (or see) XSLT or WYS... (3)
-> + Delete the xsi:nil attribute ... (2)
-> + FOTY0012: Cannot get the typed... (20)
-> + XSLT Mapper - Two way xslt map... (2)
-> + EDI (5)
-> + XSL Test for lack of XML eleme... (4)
-> + Trouble Calling a java functio... (4)
-> + How to generate EDI 997 (2)
-> + followup on tokenize with /r (5)
-> + tokenize a string with \r (4)
-> + How to convert XML to XLS file... (2)
-> - How to convert XML to XLS file... (1)
-> + how to pass value to xsl for t... (3)
-> + entity expansion liimit exceed... (4)
-> + Creating XSLT Stylesheet (2)
-> + Create XSLT from XSD (2)
-> + How to remove nodes from xml b... (4)
-> + Highlighting text in XSL file (4)
-> - XSLT to Excel, predefine cell ... (1)
-> + CSaxon8Driver issue...time out (2)
-> + Is it possible to generate a X... (2)
-> + Is there any tool which genera... (2)
-> + xslt to html producing double ... (2)
-> - ADD 2 XML 2 Generate Single XM... (1)
-> + converting XML1 to XML2 struct... (2)
-> + How to remove the name space i... (2)
-> + Dump Payload into String (4)
-> + Converting Global EDIFACT into... (2)
-> + Auto mapping of XSLT? (3)
-> + Numbering a list broken into m... (3)
-> + help in xsl:analyze-string (2)
-> + Use XSLT with SOAP (2)
-> + Order of Processing Child Elem... (2)
-> + XSL finding a node based on va... (2)
-> + grouping a group? (11)
-> + Query on Looping (5)
-> + java.lang.Assertionerror_: Slo... (7)
-> + CONVERT SQL Server data to XML... (11)
-> + Error using "xsltproc" command... (3)
-> + XML refresh via web broswer (3)
-> + XSL-mapping usage for csv file... (4)
-> + form controls with xslt (2)
-> + Stylus Studio 2011 XML Enterpr... (2)
-> + Looping through Itema and gett... (2)
-> + Image src through System Varia... (3)
-> + XSL-mapping usage for csv file... (3)
-> + How to achieve UTF-8 encoding ... (2)
-> + sorting Using JavaScript (6)
-> + Display values from .xml horiz... (5)
-> + query on xslt for-each (3)
-> + query on xslt for-each (2)
-> + issue for First occurance (2)
-> + XSL: Mapping 2 XSD to 1 XSD (2)
-> + xslt mapper looses linkage fro... (2)
-> - How to Modify only few nodes a... (1)
-> + XSLT autocomplete function (2)
-> + i need to display dynamic list... (2)
-> + How to group when source has m... (11)
-> - Using EXCEL to create XSLT for... (1)
-> + Mapper generating XSLT, popula... (2)
-> + multiple columns (2)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2016)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 01 Mar 2006 12:11 PM
Originally Posted: 01 Mar 2006 12:09 PM
Hi. I'm new to this forum as well as XSLT. I hope someone can help me solve this problem.<br> <br> I have the following XML (just part of it): <br> <br> <Segment-SDQ><br> <Element-355>CA</Element-355><br> <Element-66>9</Element-66><br> <Element-67_1>0091372090506</Element-67_1><br> <Element-380_2>428.000000</Element-380_2><br> <Element-67>0091372091009</Element-67><br> <Element-380>250.000000</Element-380><br> <Element-67_2>0091372091729</Element-67_2><br> <Element-380_1>375.000000</Element-380_1><br> <Element-67_3>0091372091919</Element-67_3><br> <Element-380_3>75.000000</Element-380_3><br> <Element-67_4>0091372092022</Element-67_4><br> <Element-380_4>310.000000</Element-380_4><br> <Element-67_5>0091372092023</Element-67_5><br> <Element-380_5>245.000000</Element-380_5><br> <Element-67_6>0091372092544</Element-67_6><br> <Element-380_6>716.000000</Element-380_6><br> <Element-67_7>0091372093052</Element-67_7><br> <Element-380_7>170.000000</Element-380_7><br> <Element-67_8>0091372093111</Element-67_8><br> <Element-380_8>85.000000</Element-380_8><br> <Element-67_9>0091372093345</Element-67_9><br> <Element-380_9>175.000000</Element-380_9><br> </Segment-SDQ><br> <br> What do I need to do as far :<br> <xsl:for-each select="Segment-SDQ/Element-67*"> The * means some code to replace there in order to repeat the loop for 67, 67_1, 67_2, 67_3, etc...<br> <br> Thanks.


Unknownsafeway.xsl


UnknownSafeway19523.xml

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 01 Mar 2006 12:41 PM
Something like...

<xsl:for-each select="Segment-SDQ/*[starts-with(local-name(), Element-67)]">
...
</xsl:for-each>

?
Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 01 Mar 2006 05:04 PM
Thanks for the reply.

This is what the XLS looks like:

<xsl:for-each select="Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ/*[starts-with(local-name(), Element-67)]"/>
<table id="DemandList1" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<b>DUNS: <xsl:value-of select="???"/></b>
</td>
</tr>
<tr>
<td>&#160;</td>
</tr>
<tr>
<td>
<table cellSpacing="1" cellPadding="2" width="100%" border="0">
<tbody>
<tr class="TDGridBrownRowTitle">
<td>Begin Date</td>
<td>End Date</td>
<td>Ship to DUNS</td>
<td>Planned Cases</td>
</tr>
<xsl:for-each select="Loop-FST">
<tr class="r{position() mod 2}">
<td>
<xsl:value-of select="Segment-FST/Element-373"/>
</td>
<td>
<xsl:value-of select="Segment-FST/Element-373_1"/>
</td>
<td>
<xsl:value-of select="???"/>
</td>
<td>
<xsl:value-of select="Segment-SDQ/Element-380_2"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table></td>
</tr>
<tr>
<td>&#160;</td>
</tr>
</tbody>
</table>
</xsl:for-each>

What should I place in place of the '???'= Element-67*

You see that I have Element-67, Element-67_1, _2, _3, _4, so on so forth and it need to xsl:for-each of them along with its corresponding elements.

Make sense?

Thanks for your help!

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 01 Mar 2006 05:22 PM
Kevin,
at that point you are already in context of any element that starts with "Element-67" (btw, make sure you put single quotes around Element-67 when you invoke the starts-with function; it won't work the way you expect right now); so, doing <xsl:value-of select="."/> should be what you want to do.

Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 08:39 AM
So there is no way I can loop any other elements(values) outside the Element-67? What should I do in order to loop Element-67 or Element-67_1, and Element-67_2 and so on?

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 09:04 AM
Kevin,
I'm not sure I understand what you are asking.

The XSLT instruction:
<xsl:for-each select="Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ/*[starts-with(local-name(), 'Element-67')]">
...
</xsl:for-each>

...will loop over *any* element child of "Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ" and whose name *starts with* "Element-67".

So, if Segment-SDQ as children elements named "Element-67" or "Element-67_1" or "Element_67_whatever_you_want_to_write_here", that for loop will cycle through all those elements. It will not cycle on children elements of Segment-SDQ named "Element-87" or "Element-peppino".

Once you are inside the for-each execution, the "context" will be your "Element-67*" node; which means that "." will be whatever "Element-67*" is the current iteration node of the for loop.

Does this help?
Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 09:22 AM
Minollo,

Thank you so much for all the help. I got it to work but...

What if I need to loop other element that is outside the Segment-SDQ/Element-67* loop? For Example:

<xsl:for-each select="Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ/*[starts-with(local-name(), 'Element-67')]">
<xsl:value-of select="."/>

<xsl: for each select="Transaction-830/Loop-LIN/Loop-FST/Segment-FST">
<xsl:value-of selected="Element-380:>
</xsl:for-each>

</xsl: for-each>

What do I need to do?

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 09:33 AM
...unless the loops need to be nested, those would qualify as two separate loops; you should rewrite them as:

<xsl:for-each select="Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ/*[starts-with(local-name(), 'Element-67')]">
<xsl:value-of select="."/>
</xsl:for-each>

<xsl: for each select="Transaction-830/Loop-LIN/Loop-FST/Segment-FST/*[starts-with(local-name(), 'Element-38')]">
<xsl:value-of selected=".">
</xsl: for-each>

Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 09:56 AM
They need to be nested. Loop#2 inside the Loop#1 but the Loop#2 needs to call elements that is outside the Loop#1.

Transaction-830
Loop-N1/Segment-N1/
[Element-97]
[Element-98]
[Element-99]
Loop-LIN/Loop-FST/Segment-SDQ/
[Element-67]
[Element-67_1]
[Element-67_2]

So I need to xsl:for-each Element-67* and inside of that I want to xsl:for-each Loop-N1/Segment-N1/ and return [Element-97], [Element-98], [Element-99].


Thansk for your help. I cannot figure this out without people like you.

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 10:06 AM
If the loops need to be nested, then you have to play with paths in expressions a bit more...

<xsl:for-each select="Transaction-830/Loop-LIN/Loop-FST/Segment-SDQ/*[starts-with(local-name(), 'Element-67')]">
<xsl:value-of select="."/>
<xsl: for each select="../../Segment-FST/*[starts-with(local-name(), 'Element-38')]">
<xsl:value-of selected=".">
</xsl: for-each>
</xsl:for-each>

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 10:42 AM
It didn't work. I need to call different Elements inside the inner loop not a sequence of elements (ex: Loop-FST/Segment-FST/Element-373, Loop-FST/Segment-FST/Element-373_1, Loop-FST/Segment-SDQ/Element-380_4)

I have attached xls and xml file to show you what I have done.

I hope you can help.


Unknownsafeway(2).xsl


UnknownSafeway19523(1).xml

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 11:15 AM
Kevin,
taking a quick look at your code and the structure of the document, I tend to think you don't need to second loop... I think you can change...

<xsl:for-each select="../../Loop-FST">
<tr class="r{position() mod 2}">
<td>
<xsl:value-of select="Segment-FST/Element-373"/>
</td>
<td>
<xsl:value-of select="Segment-FST/Element-373_1"/>
</td>
<td>
<xsl:value-of select="Segment-FST/Element-373_1"/>
</td>
<td>
<xsl:value-of select="Segment-SDQ/Element-380_2"/>
</td>
</tr>
</xsl:for-each>


...into...

<tr class="r{position() mod 2}">
<td>
<xsl:value-of select="../../Segment-FST/Element-373"/>
</td>
<td>
<xsl:value-of select="../../Segment-FST/Element-373_1"/>
</td>
<td>
<xsl:value-of select="../../Segment-FST/Element-373_1"/>
</td>
<td>
<xsl:value-of select="../Element-380_2"/>
</td>
</tr>

Does that generate what you are looking for?
Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 12:02 PM
I need to do another for-each since those elements needs to repeat according to the Element-67*

If you see the XML schema - I need to make Element-67* to be the main loop and another sets of elements that goes with it. Please my attached screenshot.


UnknownXSLT.gif

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 01:09 PM
Kevin,
please take a look at the attached modified stylesheet.

I'm not sure this outputs what you need, mostly because I'm not positive about the relationship between the DUNS and the fields in columns #1 and #2 of your image... I tried to guess that in this expression:

<xsl:for-each select="../../../Loop-FST[Segment-SDQ/*[local-name()=$element67name] = $element67value]">

...basically assuming that for each DUNS you are listing all the Element-373(_1) information that is available in any Loop-FST occurence where the same DUNS is listed in the same Element67* element... That's a complete guess on my side.

I've also grouped the DUNS (because otherwise you would endup with plenty of duplicate information), but again, I'm not sure that grouping is doing exactly what you need.

Take a look; you should be able to tweak things from here to make it work the way you need.

Minollo


Documentsafeway(3).xsl
modified xslt

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 02 Mar 2006 03:58 PM
For each DUNS i want to list all the Element-373(_1), 380_2, 234(_1), 356, 357, 355_1 information that is available in any Loop-LIN occurence where the same DUNS is listed in the same Element67* element...

I try to play around a bit more but I keep getting the same results on Element-373(_1), 380_2, 234(_1), 356, 357, 355_1 for different DUNS.

This is so complicated. I wish I can change the XML format....nothing is easy here.

Thanks a million. Can I send you some cookies?


Unknownsafeway(4).xsl


UnknownSafeway26878.xml

Postnext
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 02 Mar 2006 04:25 PM
Kevin,
unfortunately I'm not able to spend more time on this; but I would suggest that you try using the step-by-step debugging in Stylus Studio; I did find it very useful while playing with your XSLT setting a breakpoint inside the loops and running XPath instructions (Debug > Watch Window) like .., ../.., ../../../Loop-LIN and so on to understand where the context was and how I could reach other items.

Of course cookies are very welcome :)
Minollo

Postnext
Kevin YSubject: How do I do for-each on Elemenet_#'s? Please help!
Author: Kevin Y
Date: 03 Mar 2006 08:59 AM
I play around some more yesterday without luck. Thanks for your help tho!

Posttop
Minollo I.Subject: How do I do for-each on Elemenet_#'s? Please help!
Author: Minollo I.
Date: 03 Mar 2006 09:20 AM
You may want to try posting your problem on the xsl-list at mulberrytech.com

Thanks,
Minollo

   
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.