XSLT - moving nth first child as first and placing the rest of its childrens -


iam trying transform reference xml other dtd specific

input:

<ref>    <a>text</a>    <b>text</b>    <c>text</c>    <d>text</d> </ref> 

xslt:

<xsl:template match="ref">     <ref>         <h>             <xsl:apply-templates select="./a"/>         </h>         <g>             <xsl:apply-templates />         </g>     </ref> </xsl:template>  <xsl:template match="ref/a">     <a>         <xsl:apply-templates />     </a> </xsl:template> 

output derived:

<ref>   <h>      <a>text</a>   </h>   <g>      <a>text</a>      <b>text</b>      <c>text</c>      <d>text</d>   </g> </ref> 

desired output:

<ref>   <h>      <a>text</a>   </h>   <g>      <b>text</b>      <c>text</c>      <d>text</d>   </g> </ref> 

should using mode or should calling template for, if how it.

i suspect more want do:

  <xsl:template match="@* | node()">     <xsl:copy>       <xsl:apply-templates select="@* | node()"/>     </xsl:copy>   </xsl:template>    <xsl:template match="ref">     <ref>       <h>         <xsl:apply-templates select="./*[1]"/>       </h>       <g>         <xsl:apply-templates select="./*[generate-id() != generate-id(../*[1])]"/>       </g>     </ref>   </xsl:template>    <xsl:template match="ref/*">     <xsl:copy>       <xsl:apply-templates />     </xsl:copy>   </xsl:template> 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -