473,569 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="positio n()"/>
4: <xsl:for-each select="/root/ass/istance">
5: <xsl:choose>
6: <xsl:when test="number($t agfield) != number(tag/@name)">
7: <xsl:call-template name="handle-tilde"/>
8: </xsl:when>
9: <xsl:when test="number($t agfield) = 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 2606
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="positio n()"/>
4: <xsl:for-each select="/root/ass/istance">
5: <xsl:choose>
6: <xsl:when test="number($t agfield) != number(tag/@name)">
7: <xsl:call-template name="handle-tilde"/>
8: </xsl:when>
9: <xsl:when test="number($t agfield) = 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="positio n()" />

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

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

<xsl:for-each select="/root/ass/istance[number($tagfiel d) =
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="positio n()"/>
<xsl:for-each select="/root/ass/istance[not($tagfield=
preceding-sibling::istanc e/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:otherwis e>
<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
1429
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 feeds that include additional refinement by the end user. To do this we have an XSL file the display a default feed, but also presents a form that...
1
3272
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 link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
11
1900
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> <d:customerid>1049306</d:customerid> <e:professioncode b:dt="mv.string"> <c:v>byggtapetserarbeider</c:v>
0
996
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" src="Common/Template.ascx" />
0
1074
by: Wilson Wu | last post by:
Hi, How can i create a xml and xsl for more than one worksheet. Thanks Wilson
16
1839
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> ....html...
3
1376
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
1013
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 "Open with Transform," word tries to validate the XSL and complains about the xsl:stylesheet elements that dreamweaver inserts at the top of the...
6
2243
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> <loc>http://localhost/index.php/index.php/Games/The-edge-of-the- wall</loc>
5
3486
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 with this issue for several days, but there is no result. Could someone help me? <html> <head>
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.