p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 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
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_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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 30th, 2007, 04:36 PM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old 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
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old 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
Default

Hey, got it.
Its working now.
thanks for your help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old May 30th, 2007, 06:02 PM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old 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
Default

Hi,Yes i changed the same. Thanks for the update.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old 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
Default

Hi, Can i have a xsl:apply-templates inside a xsl:template element?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old 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
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT and Namspace Query. AjayLuthria XSLT 1 April 10th, 2007 12:57 PM
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 01:42 AM
How to Query XML Data from XSLT Form kwilliams XSLT 1 December 3rd, 2005 06:14 AM



All times are GMT -4. The time now is 04:04 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc