[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl/xml question

Subject: Re: xsl/xml question
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Mon, 03 Mar 2003 10:27:30 +0000
xsl value of select href
From: "Wendy Ang" <wendy@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  xsl/xml question
Date: Mon, 3 Mar 2003 18:17:20 -0800

Dear List,

I have the following XML Data format:

<ProductList>
	<Product>
		<ProductID>111</ProductID>
		<ProductName>abc</ProductName>
		...
	</Product>
</ProductList>

and I need to transform it with the corresponding XSL template using the
transformNode of MicrosoftXMLDOM

the XSL Template goes:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">
    <table border="2">
      <xsl:for-each select="/ProductList/Product">
	      <tr>
		<td>
		    Product ID: <xsl:value-of select="ProductID"/><br/>
		    Product Name: <a href="$ProductID"><xsl:value-of
select="ProductName"/></a><br/>
		    Product Code: <xsl:value-of
select="ProductCode"/><br/>
		    Description: <xsl:value-of
select="Description"/><br/>
		    Picture: <xsl:value-of select="Picture"/><br/>
		    <xsl:value-of select="Active"/><br/>
		    <xsl:value-of select="bNew"/><br/>
		    <xsl:value-of select="Special"/><br/>
		    <xsl:value-of select="AllowWriteIn"/><br/>
		    <xsl:value-of select="WriteInText"/><br/>
		    <xsl:value-of select="ListPrice"/><br/>
		    <xsl:value-of select="SellingPrice"/><br/>
		    <xsl:value-of select="PricePerUnit"/><br/>
		    <xsl:value-of select="MemberPrice"/><br/>
		    <xsl:value-of select="ActualCost"/><br/>
		    <xsl:value-of select="VolumePricing"/><br/>
		    <xsl:value-of select="VolumeQuantity"/><br/>
		    <xsl:value-of select="VolumePrice"/><br/>
		    <xsl:value-of select="VolumeEvenQuantity"/><br/>
		    <xsl:value-of
select="ApplyQuantitiesOverVolume"/><br/>
		    <xsl:value-of select="SupplierID"/><br/>
		    <xsl:value-of select="ExternalURL"/><br/>
		    <xsl:value-of select="ExtraInfoOffer"/><br/>
		    <xsl:value-of select="ExtraInfoLocation"/><br/>
		    <xsl:value-of select="Status"/><br/></td>
	      </tr>
      </xsl:for-each>
    </table>
</xsl:template>
</xsl:stylesheet>



now, if you can see this part:

    Product Name: <a href="$ProductID"><xsl:value-of
select="ProductName"/></a><br/>
		    Product Code: <xsl:value-of
select="ProductCode"/><br/>

I'm trying to get the value of ProductID and assign it to the "href"
attribute of the element <a>... anyone knows how to solve this problem?
Thanks in advance :)

Firstly aviod using the antiquated working draft transformation language indicated by:
xmlns:xsl="http://www.w3.org/TR/WD-xsl"
change this to:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
if you are using version 3 parser or better and set the selectionLanguage to "XPath". See help docs for examples.
Secondly what you need is called an Attribute Value Template. Change:
<a href="$ProductID">
to
<a href="{$ProductID}">
anything in {} will be evaluated as an XPath expression.


Joe

_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.