Ver Fonte

- proper handling of XIncludes

Jan Janak há 20 anos atrás
pai
commit
d0e46b9637
1 ficheiros alterados com 24 adições e 31 exclusões
  1. 24 31
      doc/stylesheets/dep.xsl

+ 24 - 31
doc/stylesheets/dep.xsl

@@ -1,52 +1,45 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version='1.0'
-                xmlns:xi="http://www.w3.org/2001/XInclude">
-    <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
+     version='1.0' xmlns:xi="http://www.w3.org/2001/XInclude">
 
-    <!-- Path prefix to add at the beginning of all dependencies -->
-    <xsl:variable name="prefix"/>
+    <xsl:param name="prefix"/>
+    <xsl:param name="output"/>
+
+    <xsl:template match="/">
+	<xsl:document href="{$output}" method="text" indent="no" omit-xml-declaration="yes">
+            <xsl:value-of select="concat($output, ': ')"/>
+	    <xsl:apply-templates mode="subroot"/>
+	</xsl:document>
+    </xsl:template>
 
-    <!--
-       This template gets pathname of one of the dependency files and
-       generates path prefix for other files included from that dependency.
-       This is used for .xml files included using xi:include, the function
-       returns all components of the pathname but the filename. For example
-       when called with "../modules/auth/doc/auth.xml" the template will return
-       "../modules/auth/doc/". This will be then used as the prefix for files
-       included from auth.xml, so if auth.xml includes params.xml then with the
-       prefix it will be "../modules/auth/doc/params.xml"
-    -->
     <xsl:template name="get-prefix">
-        <xsl:if test="contains($prefix, '/')">
+	<xsl:if test="contains($prefix, '/')">
 	    <xsl:value-of select="concat(substring-before($prefix, '/'), '/')"/>
 	    <xsl:call-template name="get-prefix">
-	        <xsl:with-param name="prefix" select="substring-after($prefix, '/')"/>
+		<xsl:with-param name="prefix" select="substring-after($prefix, '/')"/>
 	    </xsl:call-template>
 	</xsl:if>
     </xsl:template>
-
-    <!--
-        
-    -->
-    <xsl:template match='xi:include'>
+    
+    <xsl:template match='xi:include' mode="subroot">
 	<xsl:value-of select="concat($prefix, concat(@href, ' '))"/>
-	<xsl:apply-templates select="document(@href)">
+	<xsl:apply-templates select="document(@href)" mode="subroot">
 	    <xsl:with-param name="prefix">
-	    	<xsl:call-template name="get-prefix">
-			<xsl:with-param name="prefix" select="concat($prefix, @href)"/>
+		<xsl:call-template name="get-prefix">
+		    <xsl:with-param name="prefix" select="concat($prefix, @href)"/>
 		</xsl:call-template>
 	    </xsl:with-param>
 	</xsl:apply-templates>
     </xsl:template>
-
-    <xsl:template match='xi:include[@parse="text"]'>
+    
+    <xsl:template match='xi:include[@parse="text"]' mode="subroot">
 	<xsl:value-of select="concat($prefix, concat(@href, ' '))"/>
     </xsl:template>
-
-    <xsl:template match="graphic|imagedata|inlinemediaobject|textdata">
-        <xsl:value-of select="concat($prefix, concat(@fileref, ' '))"/>
+    
+    <xsl:template match="graphic|imagedata|inlinemediaobject|textdata" mode="subroot">
+	<xsl:value-of select="concat($prefix, concat(@fileref, ' '))"/>
     </xsl:template>
     
-    <xsl:template match="text()|@*"/>
+    <xsl:template match="text()|@*" mode="subroot"/>
 </xsl:stylesheet>
+