|
|
 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

May 30th, 2007, 03:50 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
One query in xslt
Hi,
Am trying to convert a xml to a html using an xsl.
My xml is as follows:
<?xml version="1.0"?>
<SOURCE name="store">
<GROUP hidden="N" name="ReceiptStoreAddress">
<PARAMETER final="N" hidden="N" name="emailAddress" type="STRING">
<VALUE value="email_test@group.yahoo.com"/>
</PARAMETER>
</GROUP>
<GROUP hidden="N" name="MINOR">
<PARAMETER final="N" hidden="N" name="MINOR" type="STRING">
<VALUE value="RG:36000000000000:36999999999999"/>
</PARAMETER>
</GROUP>
</SOURCE>
In the above xml, i need to access the group with the name ReceiptStoreAddress, can anyone help me how to access this group alone.When i do this, my xsl should pull out the values for the group with name ReceiptStoreAddress only and not the one with the name MINOR.
Regards,
BP
|

May 30th, 2007, 04:36 PM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
<xsl:template match="SOURCE">
<xsl:apply-templates select="GROUP[@name='ReceiptStoreAddress']"/>
</xsl:template>
<xsl:template match="GROUP">
,,,
</xsl:template>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|

May 30th, 2007, 05:38 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Michael,
Thanks for the reply.
This is what i tried, but still am not getting a proper output.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="SOURCE">
<xsl:apply-templates select="GROUP[@name='ReceiptStoreAddress']"/>
</xsl:template>
<xsl:template match="GROUP">
<html>
<body>
<h1>
<xsl:template match="VALUE">
<xsl:value-of select="@value"/>
</xsl:template>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|

May 30th, 2007, 05:41 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey, got it.
Its working now.
thanks for your help.
|

May 30th, 2007, 06:02 PM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
You can't have an xsl:template element inside another template.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|

May 30th, 2007, 06:40 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,Yes i changed the same. Thanks for the update.
|

May 30th, 2007, 06:41 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, Can i have a xsl:apply-templates inside a xsl:template element?
|

May 30th, 2007, 06:53 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is this a correct usage?
<xsl:template match="VALUE">
<html>
<body>
<h1>
<xsl:apply-templates select="PARAMETER[@name='companyName']"/>
<xsl:value-of select="@value"/>
</h1>
</body>
</html>
</xsl:template>
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |