Advertisement
Guest User

XMLMaster

a guest
May 29th, 2017
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.   <xsl:output method="xml" indent="yes"/>
  4.   <xsl:template match="*">
  5.     <xsl:copy>
  6.       <xsl:attribute name="fromRoot">
  7.            <xsl:value-of select="count(ancestor::*)"/>
  8.       </xsl:attribute>
  9.       <xsl:attribute name="preSib">
  10.            <xsl:value-of select="count(preceding-sibling::*)"/>
  11.       </xsl:attribute>
  12.       <xsl:attribute name="follSib">
  13.            <xsl:value-of select="count(following-sibling::*)"/>
  14.       </xsl:attribute>
  15.       <xsl:apply-templates select="@* | node()"/>
  16.     </xsl:copy>
  17.   </xsl:template>
  18. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement