Question: xml to csv via XSLT

Discussion in 'XML' started by quant, Mar 18, 2005.

  1. quant

    quant Guest

    Guys,

    I'm using XSLT to translate a XML file with the following structure to
    CSV.

    <AAA>
    <BBB>
    <CCC>
    <BBB>
    </BBB>
    </CCC>
    </BBB>
    </AAA>

    How do I specify a template to work on only the second level <BBB> but
    not the deepest <BBB>?

    I have to admit that this is my 2nd day using XSLT so this may sound
    stupid.

    -qt-
    quant, Mar 18, 2005
    #1
    1. Advertising

  2. quant wrote:


    > I'm using XSLT to translate a XML file with the following structure to
    > CSV.
    >
    > <AAA>
    > <BBB>
    > <CCC>
    > <BBB>
    > </BBB>
    > </CCC>
    > </BBB>
    > </AAA>
    >
    > How do I specify a template to work on only the second level <BBB> but
    > not the deepest <BBB>?


    You could use
    <xsl:template match="AAA/BBB">
    for instance to have a template for all <BBB> elements being a child of
    an <AAA> element.
    Or perhaps even
    <xsl:template match="/AAA/BBB">
    to have a template for all <BBB> elements being a child of the <AAA>
    root element.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 18, 2005
    #2
    1. Advertising

  3. quant

    Peter Flynn Guest

    Martin Honnen wrote:

    >
    >
    > quant wrote:
    >
    >
    >> I'm using XSLT to translate a XML file with the following structure to
    >> CSV.
    >>
    >> <AAA>
    >> <BBB>
    >> <CCC>
    >> <BBB>
    >> </BBB>
    >> </CCC>
    >> </BBB>
    >> </AAA>
    >>
    >> How do I specify a template to work on only the second level <BBB> but
    >> not the deepest <BBB>?

    >
    > You could use
    > <xsl:template match="AAA/BBB">
    > for instance to have a template for all <BBB> elements being a child of
    > an <AAA> element.
    > Or perhaps even
    > <xsl:template match="/AAA/BBB">
    > to have a template for all <BBB> elements being a child of the <AAA>
    > root element.


    Or (looking at it another way), match="BBB[not(descendant::BBB)]" which
    means any BBB provided it does not contain another BBB somewhere deeper.

    ///Peter
    --
    sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
    &;top"
    Peter Flynn, Mar 22, 2005
    #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. Stylus Studio
    Replies:
    0
    Views:
    621
    Stylus Studio
    Aug 3, 2004
  2. Dana B
    Replies:
    1
    Views:
    1,354
    Richard Wheeldon
    Mar 17, 2005
  3. Replies:
    4
    Views:
    647
  4. Chris
    Replies:
    12
    Views:
    2,562
    Dimitre Novatchev
    Jun 2, 2007
  5. skopeko

    XML to CSV via XSL

    skopeko, Jun 20, 2008, in forum: XML
    Replies:
    1
    Views:
    606
    skopeko
    Jun 20, 2008
Loading...

Share This Page