473,387 Members | 1,897 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,387 software developers and data experts.

xslt: continue in for-each-group?

Hello everyone,

I have just a little xslt problem:

<xsl:for-each-group select="item" group-by="name">
<xsl:if test="contains(name, 'teststring11')">
<xsl:apply-templates select="current-group()"/>
</xsl:if>
<xsl:if test="contains(name, 'teststring22')">
<xsl:apply-templates select="current-group()"/>
</xsl:if>
</xsl:for-each-group>

This xslt is fine, but has 1 problem: I want to make a "continue" in
my if clauses. If the program walks into a if clause it should go to
the next for-each-group. I don't want every if clause to be executed,
only one.

How can I do that?

Thanks very much.

bye bembi
Feb 5 '08 #1
5 6523
"bb*******@lycos.de" <bb*******@lycos.dewrites:
I have just a little xslt problem:

<xsl:for-each-group select="item" group-by="name">
<xsl:if test="contains(name, 'teststring11')">
<xsl:apply-templates select="current-group()"/>
</xsl:if>
<xsl:if test="contains(name, 'teststring22')">
<xsl:apply-templates select="current-group()"/>
</xsl:if>
</xsl:for-each-group>

This xslt is fine, but has 1 problem: I want to make a "continue" in
my if clauses. If the program walks into a if clause it should go to
the next for-each-group. I don't want every if clause to be executed,
only one.

How can I do that?
<xsl:choose?

-- Alain.
Feb 5 '08 #2
I presume you've already looked at all the grouping techniques in

http://www.dpawson.co.uk/xsl/sect2/N4486.html
http://www.dpawson.co.uk/xsl/sect2/N6280.html

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 7 '08 #3
bb*******@lycos.de wrote:
Thanks very much for the info.

Now I found out what my real problem is (I tried xsl:choose before
writing the first mail):

I have a xml like this:

<root>
<item name="111">
<subitem name="aaa">
<subitem name="bbb">
</item>....

I group the subitems but only want to output a item name once.
I want only one item output.

<xsl:for-each-group select="subitem" group-by="name">
<xsl:apply-templates select="current-group()" //here I output
the name of the parent (item) but this should be only once for every
item.
I am not sure I understand what you want to achieve, your sample has
just one item element having two subitem children with an attribute
named 'name' which has different values so there is not much to group
by. And your XPath does group-by="name", if you want to group on the
attribute you need group-by="@name".
Can you show us enough XML sample data that it becomes clear what you
want to group?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 7 '08 #4
Hello again,

given the following xml:
<root>
<item name="111">
<subitem name="aaa">
<subitem name="bbb">
<subitem name="ccc">
</item>
<item name="222">
<subitem name="ccc">
<subitem name="bbb">
</item>

If i want all item names that have the subitems aaa and ccc I want the
output:
111

but currently I get the output:
111
111

How can I do this?

thanks bembi


On 7 Feb., 17:12, Martin Honnen <mahotr...@yahoo.dewrote:
bbembi...@lycos.de wrote:
Thanks very much for the info.
Now I found out what my real problem is (I triedxsl:choose before
writing the first mail):
I have a xml like this:
<root>
<item name="111">
<subitem name="aaa">
<subitem name="bbb">
</item>....
I group the subitems but only want to output a item name once.
I want only one item output.
<xsl:for-each-group select="subitem" group-by="name">
<xsl:apply-templates select="current-group()" //here I output
the name of the parent (item) but this should be only once for every
item.

I am not sure I understand what you want to achieve, your sample has
just one item element having two subitem children with an attribute
named 'name' which has different values so there is not much to group
by. And your XPath does group-by="name", if you want to group on the
attribute you need group-by="@name".
Can you show us enough XML sample data that it becomes clear what you
want to group?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 11 '08 #5
You haven't shown your code, but this sounds like a simple matter of
rewriting the test...

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 11 '08 #6

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

Similar topics

1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by...
3
by: Tim Dempsey | last post by:
Folks, I need some advice. I hpoe some of you can advise me. Our church's weekly bulletin has been published on paper for years. It is created in MS Word and sent to the publishing company....
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
4
by: MGG | last post by:
Hi, Can anybody help me to create a xslt for the following xml matter. <orderedlist numeration="arabic"> <listitem> <para>An insurance policy paid 12 months in advance is treated as an asset...
5
by: shauldar | last post by:
Is there a way (tool, hack...) to create an XSL:FO from an XSLT + XML files? My motivation is that we want to use a tool to design reports, and from that "design" generate both HTML (via XSLT)...
4
by: Moogy | last post by:
I'm pulling my hair out here. First, I'm new to XML, so that doesn't help, but none of this makes any sense to me. All I'm trying to do is take a simple source XML file and translate it with an...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
1
by: Dan | last post by:
I have a C# program which executes some XSLT transformations. The XSLT code requires an input intermediate file, generated by other transformations, as its duty is copying some data from an input...
3
by: RC | last post by:
Let's say: if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Now I got an XML object here var xmlDocument = XMLHttpRequestObject.responseXML; // next I have...
1
by: kadykedar | last post by:
I have following XML now i want to search XML using XSLT for Solution word which is in Title element. I want to use same functionality which is provided by Like % operator in SQL queries ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.