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 1st, 2006, 02:23 PM
Authorized User
 
Join Date: Apr 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vakorde
Default xml element values

Hi frnz,

I have stuck up again in the XML parsing trhough XSL. I have an element like

<p>(a) (1) Unless otherwise specifically provided, the applicable taxable year as follows:
    <colgroup>
        <col width="2001"/>
        <col width="2003"/>
    </colgroup>
</p>

here i want to print the value
(a) (1) Unless otherwise specifically provided, the applicable taxable year as follows:
as well as the vlaues of 2001 and 2003

when i print the
<xsl:value-of select="." />
<xsl:for-each select="colgroup/col>
  <b> <xsl:value-of select="." /> </b>
</xsl:for-each>

It shows the value 2001 and 2003 twice once in bold and once in normal.

Please help me in this how to show the values only once.

Regards,
Vikrant.

__________________
---------------------------
Vikrant Korde
3i Infotech, Vashi,
Mumbai, Maharashtra, India.
 
Old May 1st, 2006, 03:22 PM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try
Code:
<xsl:value-of select="./@width"/>
 
Old May 1st, 2006, 04:23 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think your question is inaccurate, because there's nothing in your code that displays the @width attribute. Your XML source must have been different to get this effect.

Instead of xsl:value-of, use xsl:apply-templates. The default template rule for text nodes will kick in, and you can override this with a template rule for match="colgroup/col" that displays the values in bold:

<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="colgroup/col">
<b><xsl:apply-templates/></b>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 2nd, 2006, 04:36 AM
Authorized User
 
Join Date: Apr 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vakorde
Default

Yes i agree i forgot to add the attributes for width.
i don't know why am i thinking so dumb.....

thanks for the code.






Similar Threads
Thread Thread Starter Forum Replies Last Post
XML element with delimited values and XSLT Clark Kent XSLT 15 May 7th, 2008 10:10 AM
Getting value of an element in an XML file semilemon C# 2005 5 April 13th, 2007 07:54 AM
Read a XML element value chandler7272 C# 0 June 15th, 2006 02:54 AM
Converting XML to XML (making element mandatory) boondocksaint20 XSLT 8 April 28th, 2006 10:54 AM
Update a table with XML element values alavastros XML 1 July 16th, 2004 11:36 PM





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