Page 1 of 1

Generate closed tag

Posted: Mon Apr 10, 2017 6:10 pm
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

Re: Generate closed tag

Posted: Tue Apr 11, 2017 8:23 am
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

Re: Generate closed tag

Posted: Tue Apr 11, 2017 4:58 pm
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