473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with xsl:for-each

Hi to everybody,

It's possible to exit from a cycle for-each?

I have this code:

1: <xsl:for-each select="field">
2: <xsl:variable name="tagfield" select="@tag"/>
3: <xsl:variable name="pos" select="position()"/>
4: <xsl:for-each select="/root/ass/istance">
5: <xsl:choose>
6: <xsl:when test="number($tagfield) != number(tag/@name)">
7: <xsl:call-template name="handle-tilde"/>
8: </xsl:when>
9: <xsl:when test="number($tagfield) = number(tag/@name)">
10: <xsl:apply-templates select="/root/record/fields/field[$pos]"/>
11: </xsl:when>
12: </xsl:choose>
13: </xsl:for-each>
14: <xsl:value-of select="' '"/>
15: </xsl:for-each>

if the condition to the line 9 are verified it has to jump to the
"field" element following. It's possible?

thanks for the possible answers
Jul 20 '05 #1
2 2600
matatu wrote:
Hi to everybody,

It's possible to exit from a cycle for-each?

I have this code:

1: <xsl:for-each select="field">
2: <xsl:variable name="tagfield" select="@tag"/>
3: <xsl:variable name="pos" select="position()"/>
4: <xsl:for-each select="/root/ass/istance">
5: <xsl:choose>
6: <xsl:when test="number($tagfield) != number(tag/@name)">
7: <xsl:call-template name="handle-tilde"/>
8: </xsl:when>
9: <xsl:when test="number($tagfield) = number(tag/@name)">
10: <xsl:apply-templates select="/root/record/fields/field[$pos]"/>
11: </xsl:when>
12: </xsl:choose>
13: </xsl:for-each>
14: <xsl:value-of select="' '"/>
15: </xsl:for-each>

if the condition to the line 9 are verified it has to jump to the
"field" element following. It's possible?

Hi,

Disclaimer : I have not executed the following. Try this :

<xsl:for-each select="field">
<xsl:variable name="tagfield" select="@tag" />
<xsl:variable name="pos" select="position()" />

<xsl:for-each select="/root/ass/istance[number($tagfield) !=
number(tag/@name)]">
<xsl:call-template name="handle-tilde" />
</xsl:for-each>

<xsl:value-of select="' '" />

<xsl:for-each select="/root/ass/istance[number($tagfield) =
number(tag/@name)]">
<xsl:apply-template select="/root/record/fields/field[$pos]" />
</xsl:for-each>
</xsl:for-each>

This is not equivalent in processing to what you want if your input
/root/ass/istance elements need to be processed in document order. If
not, then the logic should work.

Regards,
Kenneth
Jul 20 '05 #2
> Is it possible to exit from a cycle for-each?

I don't think that possible.

But this template should mimic the behaviour you want:

<xsl:for-each select="field">
<xsl:variable name="tagfield" select="number(@tag)"/>
<xsl:variable name="pos" select="position()"/>
<xsl:for-each select="/root/ass/istance[not($tagfield=
preceding-sibling::istance/tag/@name|tag/@name)]">
<xsl:call-template name="handle-tilde"/>
</xsl:for-each>
<xsl:choose>
<xsl:when
test="count(/root/ass/istance[$tagfield = number(tag/@name)])
&gt; 0">
<xsl:apply-templates select="/root/record/fields/field[$pos]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Joris Gillis
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: deja | last post by:
Hi there, We are providing feeds via RSS/REST (query to RSS) with an attached XSL file that works quite nicely. We are now "pushing the envelope" by allowing feed-builders to build their own...
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
11
by: Rolf Barbakken | last post by:
I have an xml with records like this one: <a:response> <a:href>http://server/public/sol/comp/1049306.eml</a:href> <a:propstat> <a:status>HTTP/1.1 200 OK</a:status> <a:prop>...
0
by: David Rose | last post by:
Hello I know nothing of XSL but was wondering if it was possible to do the following: Given an XML template: <template> <register TagPrefix="whatever" TagName="Template"...
0
by: Wilson Wu | last post by:
Hi, How can i create a xml and xsl for more than one worksheet. Thanks Wilson
16
by: Indy | last post by:
Hi, I have a XHTML input file with custom tag which specifies html fragments to include For example: <html> .... <include frag1="frag1.html" frag2="frag2.html"> More html here </include>...
3
by: Al Hatch | last post by:
I have an XML file of the form: <AAA > <BBB>0001</BBB> <CCC> <DDD>0121</DDD> </CCC> <DDD> <EEE>0152</EEE> <FFF>0032</FFF>
0
by: zach.taylor.12 | last post by:
Can anyone give me advice on the following? I need to create an XSLT to display some XML data in MS Word. I have tried using Dreamweaver to create the XSL. When I try to apply the XSL by using...
6
by: Olagato | last post by:
I need to transform this: <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <loc>http://localhost/index.php/index./Paths-for-the-extreme-player</ loc> </url> <url>...
5
by: Jason | last post by:
Hi all, Are you familiar with Safari? I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. When I test xsltProcessor, there is a error as following, I have dealt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.