Hi,
You can serialize the XML in the way you want, for instance you can
parse it again and serialize empty elements with start and end tags.
In XSLT 2.0 you can use a trick to achieve that. For instance if you
know that a character, let's say # does not appear in the output then
you can use a character map to map it to nothing and generate # in every
element:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:character-map name="test">
<xsl:output-character character="#" string=""/>
</xsl:character-map>
<xsl:output use-character-maps="test"/>
<xsl:template match="*">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
<xsl:text>#</xsl:text>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
binu(_dot_)idicula(_at_)wipro(_dot_)com wrote:
Hi,
I have a translator which just copies the values of nodes and subnodes
of a selected tree.
<xsl:template match="*">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
Input
-----------------
<Name>X</Name>
<Age></Age>
Output
------------------
<Name>X</Name>
<Age/>
Is there a way to preserve the empty values, because the output is used
by a Plain Parser Application which looks for <Age> and </Age> for
looking value of Age. This legacy application is not open for editing.
regards
Binu Kuttikkattu Idicula
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--