XSLT:Preserving HTML tags from original XML.

J

Joe

How would you preserve tags from an XML element in XSLT output..

Example:

XML document has an ELEMENT "SECTION" allowing contained HTML

This element might have an element such as <A HREF="dfksdfaj">go</A>

I want the output from XSLT processing of the SECTION elements to
output
"<A HREF="dfksdfaj">go</A>" and not "go". I've tried <xsl:value-of
disable-output-encoding select="."/> and it outputs "go".

Any help will be appreciated.
 
D

David Carlisle

How would you preserve tags from an XML element in XSLT output..


XSLT has no access to the tags in the original document, it only has
access to the input tree generated by parsing those tags.
Example:

XML document has an ELEMENT "SECTION" allowing contained HTML

This element might have an element such as <A HREF="dfksdfaj">go</A>

I want the output from XSLT processing of the SECTION elements to
output
"<A HREF="dfksdfaj">go</A>" and not "go". I've tried <xsl:value-of
disable-output-encoding select="."/> and it outputs "go".

Never use disable-output-encoding unless you are in very special
circiumstances where it needs to be used, and even then avoid it if
possible, it is explictly a non portable feature of XSLT.

You just want

<xsl:copy-of select="SECTION"/>

if you want a copy of the SECTION element, or

<xsl:copy-of select="SECTION/node()"/>

if you want a copy of its children, without the surrounding SECTION.
Any help will be appreciated.

David
 
J

Joe

David Carlisle said:
XSLT has no access to the tags in the original document, it only has
access to the input tree generated by parsing those tags.



Never use disable-output-encoding unless you are in very special
circiumstances where it needs to be used, and even then avoid it if
possible, it is explictly a non portable feature of XSLT.

You just want

<xsl:copy-of select="SECTION"/>

if you want a copy of the SECTION element, or

<xsl:copy-of select="SECTION/node()"/>

if you want a copy of its children, without the surrounding SECTION.


David


Many thanks,
It worked. Will heed your other advice.

Joe
 

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,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top