xml - Select unique element by attribute using XSLT -
my xml has weird structures. being generated cms driving website, need use xml output database create print documents in adobe indesign.
i need select content wrapped in span tags have specific classes xslt not working.
here raw xml output:
<newsitem> <!doctype xsl:stylesheet[ <!entity bull "•"> ]> <inlinexml> <h2>appointments</h2> <p><span class="pb-biz red bullet">•</span> <span><strong>john smith</strong></span> interim president , ceo named permanent position.</p> <p><span class="pb-biz red bullet">•</span> hospital announced <span><strong>james williams</strong></span> become division president .</p> </inlinexml> </newsitem>
here xslt:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform version="1.0"> <xsl:output method="xml" indent="no"/> <xsl:strip-space elements="*"/> <xsl:template match="newsitem"> <newsitem><xsl:apply-templates/></newsitem></xsl:template> <xsl:template match="p"> <p><xsl:apply-templates/></p> </xsl:template> <xsl:template match="span[@class='pb-biz']"> <bull><xsl:apply-templates/></bull>"> </xsl:template> <xsl:template match="span/strong"><xsl:text> </xsl:text><biz-name><xsl:value-of select="normalize-space(.)"/></biz-name><xsl:text> </xsl:text></xsl:template> </xsl:stylesheet>
here's desired output:
<newsitem> <inlinexml> <h2>appointments</h2> <p><bull>•</bull> <biz-name>john smith</biz-name> interim president , ceo named permanent position.</p> <p><bull>•</bull> hospital announced <biz-name>james williams</biz-name> become division president.</p> </inlinexml> </newsitem>
i can't selection work bullet entity element.
thanks
your class in xml 'pb-biz red bullet'. match on class 'pb-biz'. not same, matches none. change xslt match exact attribute value of class.
Comments
Post a Comment