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:

  1. you testing existence of some p root element and contains a following sibling div. none of these true in given example;

  2. xsl:if not change context: <xsl:apply-templates select="*|text()"/> applies templates child nodes of current a;

  3. 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

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -