467,920 Members | 1,246 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

An XSLT that does nothing

Hi,

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

Thank you.

Sarah Haff
Jul 20 '05 #1
  • viewed: 6031
Share:
4 Replies


Sarah Haff wrote:
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
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
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. :)

http://www.w3.org/TR/xslt#copying

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

Thank you.
Sarah
Jul 20 '05 #3
sa********@hotmail.com (Sarah Haff) writes:
If doing nothing means copying the source document unchanged then you
need the identity transformation, see

This IS what I am looking for. :)

http://www.w3.org/TR/xslt#copying

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

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #4


Sarah Haff wrote:

If doing nothing means copying the source document unchanged then you
need the identity transformation, see


This IS what I am looking for. :)
http://www.w3.org/TR/xslt#copying


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.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by K. N. | last post: by
9 posts views Thread by Jeff Rubard | last post: by
5 posts views Thread by Fred | last post: by
1 post views Thread by Wil | last post: by
3 posts views Thread by Jack Fox | last post: by
4 posts views Thread by Moogy | last post: by
reply views Thread by Christopher M. Lauer | last post: by
7 posts views Thread by One Handed Man \( OHM - Terry Burns \) | last post: by
reply views Thread by Terry Brown | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.