Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT queries ... <xsl:copy-of>, etc.

Status
Not open for further replies.

arvin21

Programmer
May 23, 2002
5
PH
GIVEN:
Code:
<xsl:output omit-xml-declaration=&quot;no&quot; encoding=&quot;utf-8&quot; indent=&quot;no&quot; media-type=&quot;text/xml&quot;/>


1. Using XSLT, how do I prevent &quot;empty&quot; elements (elements not having data and not elements with EMPTY declaration) from converting to XML empty syntax?

INPUT:
Code:
<entry></entry>

OUTPUT:
Code:
<entry/>

DESIRED OUTPUT:
Code:
<entry></entry>


2. XSLT converts &apos; and
Code:
&quot;
. Is there a way for XSLT not to convert these two entities. XSLT retains
Code:
&lt; &gt;
and
Code:
&amp;
.

INPUT:
Code:
&lt; &gt; &amp; and&quot; stages&apos;

OUTPUT:
Code:
&lt; &gt; &amp; and&quot; stages'

DESIRED OUTPUT:
Code:
&lt; &gt; &amp; and&quot; stages&apos;


3. I need to preserved certain markups in my XML file. For example, all data within <myTag>. <xsl:copy-of> is not working. How do I do it in XSLT?

INPUT:
Code:
<p>data data &hellip;<myTag>&auml;</myTag>&hellip; data data.</p>

OUTPUT:
Code:
<p>data data ...<myTag>ä</myTag>... data data.</p>

DESIRED OUTPUT:
Code:
<p>data data ...<myTag>&auml;</myTag>... data data.<p>


Thanks for all the help!
 
If you use the Saxon xslt transformer (for Java) it will leave any empty elements.

As far as keeping your markup try using a <xsl:text> tag
 
Just do this;
<xsl:text disable-output-escaping=&quot;yes&quot;>
BLAH BLAH BLAH
</xsl:text>
If I misunderstand your quesiton due to the ridiculous processing of entities in [ code ] and [ /code ] segments, please correct me.


Regards,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top