Avoid XSLT output of partial XML subtrees

Discussion in 'XML' started by trash.muell@gmx.net, Mar 13, 2007.

  1. Guest

    Hi,

    I am struggling with an XSLT task and need a hint: I have a complex
    XML file but want to only output some sub-trees of the XML structure.
    My XSLT script is always printing the information of the whole XML
    file. Only if I explicitely exclude subtrees/nodes with

    <xsl:template match="anExcludedNode" />

    their content doesn't appear in the output. Is this the only way to do
    it? The problem is that If at a later stage further nodes will be
    added the XSLT scripts have to be modified to "exclude" the content
    output of the new trees.

    Thanks a lot in advance!

    Tras
    , Mar 13, 2007
    #1
    1. Advertising

  2. * wrote in comp.text.xml:
    >I am struggling with an XSLT task and need a hint: I have a complex
    >XML file but want to only output some sub-trees of the XML structure.
    >My XSLT script is always printing the information of the whole XML
    >file. Only if I explicitely exclude subtrees/nodes with
    >
    ><xsl:template match="anExcludedNode" />
    >
    >their content doesn't appear in the output. Is this the only way to do
    >it? The problem is that If at a later stage further nodes will be
    >added the XSLT scripts have to be modified to "exclude" the content
    >output of the new trees.


    You cannot avoid to specify at some point which nodes should be ignored
    or processed. What you can do is select the appropriate subtree in your
    xsl:apply-template calls using their select attribute. Most likely there
    are other ways better suited for your problem, but you don't provide
    enough information to make a better suggestion.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Mar 13, 2007
    #2
    1. Advertising

  3. Insufficient information. Possible solutions include inverting the
    question and copying only nodes you want to keep, or writing a more
    general match pattern for those you want to discard, or using modes to
    help control those alternatives, or...

    XSLT is a programming language. Start by spelling out EXACTLY what
    you're trying to accomplish, in the simplest but most complete language
    possible, remembering that XSLT's most basic operation is to copy
    information from the input document to the output document. Without a
    maximally clear and precise description of your problem, you'll find it
    hard to design the best solution.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Mar 14, 2007
    #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. Billy
    Replies:
    2
    Views:
    489
    Billy
    Feb 1, 2006
  2. Thomas Heller
    Replies:
    13
    Views:
    842
    Michele Simionato
    Feb 8, 2007
  3. J. Clifford Dyer

    Re: Partial 1.0 - Partial classes for Python

    J. Clifford Dyer, Feb 8, 2007, in forum: Python
    Replies:
    0
    Views:
    509
    J. Clifford Dyer
    Feb 8, 2007
  4. Ryan Nordman

    Comparing Subtrees in XSLT

    Ryan Nordman, Jul 21, 2007, in forum: XML
    Replies:
    4
    Views:
    862
    Joe Kesselman
    Jul 24, 2007
  5. Manfred Braun

    TreeView:Cannot add subtrees from xml [using

    Manfred Braun, Aug 22, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    130
    Manfred Braun
    Aug 22, 2004
Loading...

Share This Page