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
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
dev user06Subject: xslt - get values from fist node of duplicate nodes
Author: dev user06
Date: 08 Aug 2006 11:09 AM
Hi,

I have my xml, xslt below ; I know why it is giving me the above output but don't know how to fix this so that it can get me the desired output.....

The below xslt works only if we have the same id for all items.What if I want to get the values form other items with other id's too...
Using the below xslt I get COMPUTERS:P4 AND BOOK3

whereas the desired output is :
COMPUTERS:P4 LAPTOPS FOR RECORD1
BOOK3 CHAIRS FOR RECORD2


This is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<f:root xmlns:f="http://www.w3schools.com/furniture">
<f:record>
<f:item id="600">
<f:book code="a">COMPUTERS:P4</f:book>
</f:item>
<f:item id="600">
<f:book code="a">COMPUTERS:P3</f:book>
</f:item>
<f:item id="700">
<f:book code="a">LAPTOPS</f:book>
</f:item>

</f:record>
<f:record>
<f:item id="100">
<f:book code="a">BOOK3</f:book>
</f:item>
<f:item id="100">
<f:book code="a">BOOK4</f:book>
</f:item>
<f:item id="700">
<f:book code="a">CHAIRS</f:book>
</f:item>
</f:record>
</f:root>

---------------------------------------------------------
[b] This is my xslt [b]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:f="http://www.w3schools.com/furniture">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="f:root/f:record">
<xsl:for-each select="f:item[1]">
<xsl:if test="@id=100">
<xsl:value-of select="."/> <br/>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="f:item[1]">
<xsl:if test="@id=600">
<xsl:value-of select="."/> <br/>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="f:item[1]">
<xsl:if test="@id=700">
<xsl:value-of select="."/> <br/>
</xsl:if>
</xsl:for-each>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks a ton!!!!!!

Postnext
Ivan PedruzziSubject: xslt - get values from fist node of duplicate nodes
Author: Ivan Pedruzzi
Date: 08 Aug 2006 02:45 PM

Dear dev.user06,

Which Stylus Studio version are you running?


Ivan Pedruzzi
Stylus Studio Team

Postnext
dev user06Subject: xslt - get values from fist node of duplicate nodes
Author: dev user06
Date: 08 Aug 2006 03:23 PM
Hi,
I'm not using stylus studio, I use saxon xslt processor
to parse my xml ........

I need help to get the desired output using xslt1.0 or in any other form.....

can someone please help me with this!

Postnext
Ivan PedruzziSubject: xslt - get values from fist node of duplicate nodes
Author: Ivan Pedruzzi
Date: 08 Aug 2006 03:42 PM

Try posting on the XSLT mailing list
http://www.mulberrytech.com/xsl/xsl-list/


Ivan

Posttop
James DurningSubject: xslt - get values from fist node of duplicate nodes
Author: James Durning
Date: 10 Aug 2006 05:18 PM
Try using the muenchian grouping method.
http://www.jenitennison.com/xslt/grouping/muenchian.html

Not exactly sure how you're mapping your data.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
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.