An XSLT that does nothing

S

Sarah Haff

Hi,

What would be minimilistic XSLT that does "nothing" (no
transformation) to the given XML content.

Thank you.

Sarah Haff
 
M

Martin Honnen

Sarah said:
What would be minimilistic XSLT that does "nothing" (no
transformation) to the given XML content.

An empty template for the document root node should do nothing

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/" />

</xsl:stylesheet>

in the sense that it outputs nothing.

If doing nothing means copying the source document unchanged then you
need the identity transformation, see
http://www.w3.org/TR/xslt#copying
 
S

Sarah Haff

Hi Martin,
An empty template for the document root node should do nothing
<xsl:stylesheet version="1.0"
......
in the sense that it outputs nothing.
This wasn't what I was looking for. I should have been more clear in
my original question ;)
If doing nothing means copying the source document unchanged then you
need the identity transformation, see
This IS what I am looking for. :)

Is this the best (minilistic) was of doing this ? :-/

Thank you.
Sarah
 
B

Ben Edgington

This IS what I am looking for. :)


Is this the best (minilistic) was of doing this ? :-/

This is pretty small too:

<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>

Which is minimal is moot.

Ben
 
M

Martin Honnen

Sarah Haff wrote:

This IS what I am looking for. :)




Is this the best (minilistic) was of doing this ? :-/

Not quite, rather it is a good start if you want to copy most of the XML
but want to change some nodes, then you can usually start with that
identity transformation and add templates for those nodes that you want
to change.
If really copying is all you need then the template Ben has posted is
more minimalistic as it simply copies the document node with all child
nodes.
 

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
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top