using regular expression in xslt 1.0 -
i want use regular expression in xslt 1.0
input
<book> <p> clavicle broken more <inlinegraphic></inlinegraphic> mad_2235.eps other bone in body </p> </book>
output
<book> <p> clavicle broken more <graphic name="mad_2235.eps" source="isbn" in-line="yes"/> other bone in body </p> </book>
thanks, muthu
xslt 1.0 doesn't regular expressions, don't think need them in case. start identity transformation
<!-- copy input output verbatim, except overridden more specific templates --> <xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy> </xsl:template>
then override template matches text node follows inlinegraphic
element , contains .eps
<xsl:template match="text()[preceding-sibling::node()[1][self::inlinegraphic]] [contains(., '.eps')]"> <!-- take before first .eps graphic name --> <graphic name="{normalize-space(substring-before(., '.eps'))}.eps" source="isbn" in-line="yes"/> <!-- , leave after normal text --> <xsl:value-of select="substring-after(., '.eps')" /> </xsl:template>
and add template remove inlinegraphic
element itself
<xsl:template match="inlinegraphic" />
Comments
Post a Comment