...

View Full Version : xsl attribute value display



bluephoenix
12-30-2002, 07:05 PM
Well, I've decided it's time for me to learn XML... (Yes, I'm a newbie, but eager to learn).

I'm attempting to create an XML document which uses an external DTD and an external xsl to create an HTML document.

My DTD defines my share tag as:



<! ELEMENT share EMPTY >
<! ATTLIST share
type CDATA #REQUIRED
APY CDATA #REQUIRED
APR CDATA #REQUIRED
minBal CDATA #REQUIRED>


While my XML document resemebles:



<rates>
<share type="Savings" APY="2.00" APR="2.02" minBal="10.00"/>
<share type="MoneyMarket" APY="3.00" APR="3.03" minBal="1000.00"/>
<share type="IRA" APY="2.00" APR="2.02" minBal="10.00"/>
</rates>


Now I want to be able to generate a table with that information. I know how to select the particular attribute with <xsl:attribute name="type">, but how do I display the value of that attribute?

Thanks everyone.

brothercake
12-30-2002, 07:51 PM
With the @ symbol:

<xsl:value-of select="@attribute_name"/>


but BTW and IMHO you shouldn't really keep data in attributes. Atrributes are best used for meta-data such as an object ID. Something like:

<share>
<type>Savings</type>
<apy>2.00</apy>
<apr>2.02</apr>
<minBal>10.00</minBal>
</share>

would be better.

bluephoenix
12-30-2002, 10:19 PM
Thanks!

... just a humorous aside, I used <xml:value-of select="@type">. but my document still would not display. I was racking my brain again when I realized I had forgotten the <xsl:apply-templates/>!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum