RE: [xsl] Insert space after the closing element

Subject: RE: [xsl] Insert space after the closing element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 22 Jan 2010 09:29:48 -0000
In your match="legis-site" template, you are currently adding a newline
unconditionally using the xsl:text element. You can change this to output
the newline conditionally using something like

<xsl:if test="not(matches(following-sibling::text()[1],
"^[-,:;;]"))"><xsl:text>
</xsl:text></xsl:if>

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: Selvaganesh [mailto:selvaganesh_t@xxxxxxxxxxxxxx] 
> Sent: 22 January 2010 07:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Insert space after the closing element
> 
> Dear Team,
> 
> In my xslt developed as to be insert the space before the 
> opening tag & after the closing tag. But after space do not 
> insert few condition. (e.g. if found the dot, comma, colon, 
> semi-colon & mdash after closing tags do not insert the space.)
> 
> This is my current XSLT:
> 
> <hov:stylesheet xmlns:hov="http://www.w3.org/1999/XSL/Transform";
>  xpath-default-namespace="http://xml.smg-uk.com/schema/cases/report";
> version="2.0">
> 
> <hov:import href="Entity/entitynamesmap.xsl"/>
> <hov:output method="xml" indent="yes"
> use-character-maps="w3c-entity-names"/>
> 
> <hov:template match="text()">
> <hov:value-of select="normalize-space()"/> </hov:template>
> 
> <hov:template match="report">
> <hov:element name="report"><hov:apply-templates/></hov:element>
> </hov:template>
> 
> <hov:template match="para">
> <hov:element name="para-text">
> <hov:attribute name="indent"><hov:text>1</hov:text></hov:attribute>
> <hov:apply-templates/></hov:element>
> </hov:template>
> 
> <hov:template match="legis-cite"><hov:text> 
> </hov:text><hov:element 
> name="citation"><hov:apply-templates/></hov:element><hov:text>
> </hov:text></hov:template>
> </hov:stylesheet>
> 
> This is my current Output: (do not insert the space after the 
> "Rights arts 8</citation> and 11</citation>" or remove space 
> before the "dot, comma, colon, semi-colon & mdash" after the 
> transformed file.
> 
>                <para-text indent="1"> 
>                   <citation>European Convention on Human 
> Rights arts 8</citation> , <citation>10</citation> and 
> <citation>11</citation> .
>                </para-text>
> 
> Actual required:
> 
>                <para-text indent="1"> 
>                   <citation>European Convention on Human 
> Rights arts 8</citation>, <citation>10</citation> and 
> <citation>11</citation>.
>                </para-text>
> 
> This is input: 
> 
> <para id="89471df0-f798-430f-bfd1-b0dc6e53bfee"><legis-cite>
>                             <ancestor-part id="bfd1"/>
>                             <ancestor-part id="bfd1a"/>European
>                             Convention on Human Rights arts 
> 8</legis-cite>, <legis-cite>
>                             <ancestor-part id="bfd2"/>
>                             <ancestor-part 
> id="bfd2a"/>10</legis-cite> and <legis-cite>
>                             <ancestor-part id="bfd3"/>
>                             <ancestor-part 
> id="bfd3a"/>11</legis-cite>.</para>
> 
> Kindly guide me how can I modify in my XSLT.
> 
> Thanks,
> Selva
> 
> 
> Confidentiality Notice:  This transmittal is a confidential 
> communication.  If you are not the intended recipient, you 
> are hereby notified that you have received this transmittal 
> in error and that any review, dissemination, distribution or 
> copying of this transmittal is strictly prohibited.  If you 
> have received this communication in error, please notify this 
> office immediately by reply and immediately delete this 
> message and all of its attachments, if any.

Current Thread