Generate closed tag

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
sderrick
Posts: 219

Generate closed tag

Mon Apr 10, 2017 6:10 pm

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: 5867

Re: Generate closed tag

Tue Apr 11, 2017 8:23 am

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: 219

Re: Generate closed tag

Tue Apr 11, 2017 4:58 pm

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

Return to “Common Problems”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests