XSL Newbie but a really annoying problem

Discussion in 'XML' started by danmat46@googlemail.com, Jan 29, 2008.

  1. Guest

    Morning all,
    Just started out with XSL.
    Now working on my first example I have the following XML structure

    <topLevel>
    <repeatLevel name="hello" type="hello">
    <![CDATA[sometext in here]]>
    </repeatLevel>
    <repeatLevel name="hello2" type="hello2">
    <![CDATA[more text in here]]>
    </repeatLevel>
    </topLevel>

    Now developing the XSL is going fine, I have an html table with three
    columns and been able to output the name and type but I cannot get the
    CDATA's text in the third column.

    Is this possible?

    And no unfortunatly I cannot change the XML format to add the CDATA as
    an attribute.

    Any help welcomed!

    Thank you
     
    , Jan 29, 2008
    #1
    1. Advertising

  2. Pavel Lepin Guest

    <> wrote in
    <>:
    > Now working on my first example I have the following XML
    > structure
    >
    > <topLevel>
    > <repeatLevel name="hello" type="hello">
    > <![CDATA[sometext in here]]>
    > </repeatLevel>
    > <repeatLevel name="hello2" type="hello2">
    > <![CDATA[more text in here]]>
    > </repeatLevel>
    > </topLevel>
    >
    > Now developing the XSL is going fine, I have an html table
    > with three columns and been able to output the name and
    > type but I cannot get the CDATA's text in the third
    > column.
    >
    > Is this possible?


    Yes, it is possible.

    --
    ....also, I submit that we all must honourably commit seppuku
    right now rather than serve the Dark Side by producing the
    HTML 5 spec.
     
    Pavel Lepin, Jan 29, 2008
    #2
    1. Advertising

  3. wrote:
    > Morning all,
    > Just started out with XSL.
    > Now working on my first example I have the following XML structure
    >
    > <topLevel>
    > <repeatLevel name="hello" type="hello">
    > <![CDATA[sometext in here]]>
    > </repeatLevel>
    > <repeatLevel name="hello2" type="hello2">
    > <![CDATA[more text in here]]>
    > </repeatLevel>
    > </topLevel>
    >
    > Now developing the XSL is going fine, I have an html table with three
    > columns and been able to output the name and type but I cannot get the
    > CDATA's text in the third column.
    >
    > Is this possible?


    Sure, why not? In the XSLT/XPath data model there are no CDATA sections
    anyway, the repeatLevel elements simply have a string value so you can
    do e.g.
    <xsl:template match="repeatLevel">
    <tr>
    <td><xsl:value-of select="@name"/></td>
    <td><xsl:value-of select="@type"/></td>
    <td><xsl:value-of select="."/></td>
    </tr>
    </xsl:template>

    Or with additonal templates you do e.g.

    <xsl:template match="repeatLevel">
    <tr>
    <xsl:apply-templates select="@* | node()"/>
    </tr>
    </xsl:template>

    <xsl:template match="repeatLevel/@* | repeatLevel/text()">
    <td>
    <xsl:value-of select="."/>
    </td>
    </xsl:template>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 29, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nc
    Replies:
    1
    Views:
    527
    nice.guy.nige
    Feb 3, 2005
  2. Mr. SweatyFinger

    really annoying

    Mr. SweatyFinger, Dec 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    =?Utf-8?B?Q2lhcmFuIE8nJycnRG9ubmVsbA==?=
    Dec 21, 2006
  3. UKuser

    Really annoying

    UKuser, Apr 24, 2007, in forum: HTML
    Replies:
    1
    Views:
    340
    Neredbojias
    Apr 24, 2007
  4. Charles Fox
    Replies:
    56
    Views:
    1,229
    Ben Finney
    Sep 19, 2007
  5. Simon Brooke
    Replies:
    6
    Views:
    1,363
    Michelle Steiner
    Sep 26, 2010
Loading...

Share This Page