Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Central New York
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    xsl attribute value display

    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:

    Code:
    <! ELEMENT share EMPTY >
    <! ATTLIST share
           type         CDATA     #REQUIRED
           APY          CDATA     #REQUIRED
           APR          CDATA     #REQUIRED
           minBal       CDATA     #REQUIRED>
    While my XML document resemebles:

    Code:
    <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.
    Timothy Boronczyk

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Dec 2002
    Location
    Central New York
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/>!
    Timothy Boronczyk


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •