How do I extract a repeating attribute value out to display it only once (using XSLT 1.0).

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mark4asp

    How do I extract a repeating attribute value out to display it only once (using XSLT 1.0).

    Apologies, I just can't get my head around xslt but I need to do this.

    I have an xml file with two attributes per product. One of the
    attributes repeats to produce several groups (3 in the example, grouped
    by region). How can I select this repeating attribute out as a header
    column in a table with the other attribute as in a data column. (see
    example html). XSLT 1.0 solutions only please (or whatever is
    compatible with current major browser parsers [FF, IE6, IE7, Opera,
    Safari]).

    source xml:

    <sales>
    <product region="NW" item="Drill" />
    <product region="NW" item="Fork" />
    <product region="NW" item="Spade" />
    <product region="SE" item="Brick" />
    <product region="SE" item="Hammer" />
    <product region="SE" item="Nail" />
    <product region="SW" item="Chisel" />
    <product region="SW" item="Screw" />
    </sales>

    target html:

    <html>
    <body>
    <table>
    <tr><th>NW</th></tr>
    <tr><td>Drill </td></tr>
    <tr><td>Fork</td></tr>
    <tr><td>Spade </td></tr>
    <tr><th>SE</th></tr>
    <tr><td>Brick </td></tr>
    <tr><td>Hamme r</td></tr>
    <tr><td>Nail</td></tr>
    <tr><th>SW</th></tr>
    <tr><td>Chise l</td></tr>
    <tr><td>Screw </td></tr>
    </table>
    </body>
    </html>

  • Richard Tobin

    #2
    Re: How do I extract a repeating attribute value out to display it only once (using XSLT 1.0).

    In article <023e2a0a$0$200 24$c3e8da3@news .astraweb.com>,
    mark4asp <mark4asp@gmail .comwrote:
    >I have an xml file with two attributes per product. One of the
    >attributes repeats to produce several groups (3 in the example, grouped
    >by region). How can I select this repeating attribute out as a header
    >column in a table with the other attribute as in a data column.
    You may find this helpful:



    -- Richard
    --
    :wq

    Comment

    Working...