473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Avoid XSLT output of partial XML subtrees

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 '07 #1
2 2258
* tr*********@gmx.net 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:bj****@hoehrmann.de · 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/
Mar 13 '07 #2
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
Mar 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
2
by: Taare | last post by:
Hi, I got <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system=" http://www.w3.org/TR/html4/strict.dtd"/> in my XSLT file. This should remove...
3
by: danmc91 | last post by:
Hi, I'm just getting going with xml and xslt. I'm trying to write what are essentially man pages and I need 3 output formats. 1) nroff -man format for real man pages 2) html for an online...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
15
by: Jeff Uchtman | last post by:
Can I draw from 2 XML sources, the structure is exactly the same execpt for data contained into 1 xslt using math to add some structrure, and displaying others as node 1 and node 2? This data is...
2
by: Ryan Nordman | last post by:
Hey XML gurus, Is there a way to write a template so that it will compare two XML subtrees wholesale? I can't quite get my head around this problem. Let's say I have these two XML trees, both...
0
by: Thomas Wittek | last post by:
Hi! I'm using xsl:attribute-sets to reduce redundancy in my XSLT. An example from a transformation to XHTML (the attribute values are simply copied from input to output): <xsl:attribute-set...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.