I have the following XML structure:
<method constructor="true" name="Main" public="true">
<parameterList/>
<block>
<call>
<callAttrbute>
<variable name="addEventListener"/>
</callAttrbute>
<fieldAccess target="Event" name="ENTER_FRAME"/>
<variable name="onEnterFrame"/>
</call>
<block>
</method>
The XML represents the structure of the follow code:
public function Main(){
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
My template looks something like:
<xsl:template match="method">
<xsl:choose>
<xsl:when test="@public">public </xsl:when>
<xsl:otherwise>private </xsl:otherwise>
</xsl:choose>
<xsl:if test="@static"><xsl:text>static </xsl:text></xsl:if>
<xsl:value-of select="@name" />
<xsl:apply-templates select="*" />
</xsl:template>
I want the following output (the same,just for example):
public function Main(){
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
But the translate result is:
public Main()
{
addEventListener
(Event.ENTER_FRAME,onEnterFrame);
}
In the result there are so many unwanted newlines and spaces, and it seems that the new line comes from the stylesheet.
How can I get the right format?
The only way I know to prevent unwanted newlines is concatenating stuff in xslt itself like the below. This gives the required result in XML Spy 2011, but may not give the same in (for example) Saxon.
When applied to the given input, this leads to (in XML Spy):