Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2007, 02:50 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 protected]"/>
        </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
 
Old May 30th, 2007, 03:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<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
 
Old May 30th, 2007, 04:38 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>
 
Old May 30th, 2007, 04:41 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey, got it.
Its working now.
thanks for your help.
 
Old May 30th, 2007, 05:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old May 30th, 2007, 05:40 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,Yes i changed the same. Thanks for the update.
 
Old May 30th, 2007, 05:41 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, Can i have a xsl:apply-templates inside a xsl:template element?
 
Old May 30th, 2007, 05:53 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT and Namspace Query. AjayLuthria XSLT 1 April 10th, 2007 11:57 AM
Query About XSLT-Urgent harshalchoksi XSLT 6 February 23rd, 2007 06:43 AM
Can XSLT read DTD/schema and Generate XSLT.. ROCXY XSLT 1 November 6th, 2006 09:39 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
How to Query XML Data from XSLT Form kwilliams XSLT 1 December 3rd, 2005 06:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.