xslt - Attempts to use following-sibling to convert -
i try convert old html xslt-script new xml stucture. have problem converting folowing source needed xml structure.
source
<p> <a class="dropdown">example text</a> </p> <div class="collapsed"> <table>..</table> <p>..</p> </div>
xml structure
<lq> <p>example text</p> <table>..</table> <p>..</p> </lp>
i tried following xls, div class="collapsed" not adopted lp tag.
<xsl:template match="p/a[@class='dropdown']"> <lp> <p><xsl:apply-templates select="text()"/></p> <xsl:if test="/p/a/following-sibling::*[1][self::div]"> <xsl:apply-templates select="*|text()"/> </xsl:if> </lp> </xsl:template>
can tell me did wrong ore mistake is?
thanks much
imho, want do:
<!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="p[a/@class='dropdown']"> <lp> <p> <xsl:value-of select="a"/> </p> <xsl:copy-of select="following-sibling::*[1][self::div]/node()"/> </lp> </xsl:template> <xsl:template match="div[preceding-sibling::*[1][self::p/a/@class='dropdown']]"/>
as mistake:
you testing existence of some
p
root element and containsa
following sibling div. none of these true in given example;xsl:if
not change context:<xsl:apply-templates select="*|text()"/>
applies templates child nodes of currenta
;presumably don't want
div
appear again in original place - if have template suppress it, cannot use<xsl:apply-templates>
insert @ place want - @ least not without using mode.
Comments
Post a Comment