Generate closed tag

Having trouble installing Oxygen? Got a bug to report? Post it all here.
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Generate closed tag

Post by sderrick »

When transforming into xml can I generated a closed tag?

In my xsl file I have
<origPlace/>
in the resulting document
<origPlace/></origin>
anyway to have the tag generated with as it is in the xsl file?

thanks,

Scott
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Generate closed tag

Post by Radu »

Hi Scott,

Your example is quite unclear, do you mean that initially the XML element is collapsed like <x/> and then in the output file it is expanded like <x></x>?
Usually from what I tried most XSLT processors will output the empty tag in collapsed format. I tried with Saxon 6 and Saxon 9 and they both generated the collapsed form of the element.
You can try for example applying a copy XSLT stylesheet to the XML document:

Code: Select all

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
There is no setting in Oxygen to control this when transforming.
What you can do is to open the result XML document in Oxygen and use the "Format and Indent" toolbar action on it. There is a format and indent setting which can be toggled to instruct Oxygen what form to use for empty elements, by default it collapses them.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Generate closed tag

Post by sderrick »

Radu,

thanks for the quick reply.

I figured out how to do it.

If your input is <foo></foo>, the output is <foo/>
If your input is <foo/>, the output is <foo></foo>

counter intuitive but I've found Saxon is like that in many ways.

thanks again,

Scott
Post Reply