XSLTools

XSLForms/XSL/Extract.xsl

178:7e7d9dbcec62
2005-07-22 paulb [project @ 2005-07-22 18:26:38 by paulb] Tidied up the function names and added some API documentation. Added child-element and child-attribute functions for coherent references to potentially non-existent nodes in the form data.
     1 <?xml version="1.0"?>     2 <xsl:stylesheet version="1.0"     3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"     4   xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"     5   xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"     6   xmlns:dyn="http://exslt.org/dynamic"     7   extension-element-prefixes="dyn">     8      9   <xsl:output indent="yes"/>    10   <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>    11     12   <xsl:param name="element-id"/>    13     14     15     16   <!-- Start at the top, finding only the specified element. -->    17     18   <xsl:template match="/">    19     <axsl:stylesheet version="1.0"    20       xmlns:dyn="http://exslt.org/dynamic"    21       extension-element-prefixes="dyn">    22     23       <axsl:output indent="yes"/>    24       <axsl:param name="element-path"/>    25     26       <!-- NOTE: Hard-coded doctypes to hopefully satisfy JavaScript code. -->    27       <!-- doctype-public="-//W3C//DTD XHTML 1.1//EN"    28         doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->    29     30       <axsl:template match="/">    31     32         <!-- Include the remaining attributes. -->    33         <xsl:apply-templates select="@*"/>    34     35         <!-- Process the elements. -->    36         <xsl:for-each select="//*[@template:id=$element-id]">    37           <axsl:for-each select="dyn:evaluate($element-path)">    38             <xsl:copy>    39               <xsl:apply-templates select="@*|node()"/>    40             </xsl:copy>    41           </axsl:for-each>    42         </xsl:for-each>    43     44       </axsl:template>    45     </axsl:stylesheet>    46   </xsl:template>    47     48     49     50   <!-- Replicate unknown elements. -->    51     52   <xsl:template match="@*|node()">    53     <xsl:copy>    54       <xsl:apply-templates select="@*|node()"/>    55     </xsl:copy>    56   </xsl:template>    57     58 </xsl:stylesheet>