Avoid XSLT output of partial XML subtrees

T

trash.muell

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
 
B

Bjoern Hoehrmann

* (e-mail address removed) 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.
 
J

Joe Kesselman

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,268
Members
46,867
Latest member
Lonny Petersen

Latest Threads

Top