You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2005/11/25 00:59:12 UTC

svn commit: r348835 - /myfaces/impl/trunk/tld/misc/resolve_entities.xsl

Author: skitching
Date: Thu Nov 24 15:59:09 2005
New Revision: 348835

URL: http://svn.apache.org/viewcvs?rev=348835&view=rev
Log:
Pretty print the generated tld, so the entity files don't need to get the indenting exactly right

Modified:
    myfaces/impl/trunk/tld/misc/resolve_entities.xsl

Modified: myfaces/impl/trunk/tld/misc/resolve_entities.xsl
URL: http://svn.apache.org/viewcvs/myfaces/impl/trunk/tld/misc/resolve_entities.xsl?rev=348835&r1=348834&r2=348835&view=diff
==============================================================================
--- myfaces/impl/trunk/tld/misc/resolve_entities.xsl (original)
+++ myfaces/impl/trunk/tld/misc/resolve_entities.xsl Thu Nov 24 15:59:09 2005
@@ -1,17 +1,45 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  - Stylesheet to pretty-print an xml document. In addition, if the input
+  - document contains any xml entity references, then those are expanded
+  - inline.
+  -
+  - Based on a stylesheet by John Mongan.
+  -->
 <xsl:stylesheet version="1.1"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
     <xsl:output method="xml"
+                indent="yes"
                 encoding="ISO-8859-1"
                 doctype-public="-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
-                doctype-system="http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"
-        />
+                doctype-system="http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"/>
 
-    <xsl:template match="@*|node()">
+    <xsl:param name="indent-increment" select="'   '" />
+
+    <xsl:template match="*">
+      <xsl:param name="indent" select="'&#xA;'"/>
+
+      <xsl:value-of select="$indent"/>
       <xsl:copy>
-        <xsl:apply-templates select="@*|node()"/>
+        <xsl:copy-of select="@*" />
+        <xsl:apply-templates>
+          <xsl:with-param name="indent"
+               select="concat($indent, $indent-increment)"/>
+        </xsl:apply-templates>
+        <xsl:if test="*">
+          <xsl:value-of select="$indent"/>
+        </xsl:if>
       </xsl:copy>
     </xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+   <xsl:template match="comment()|processing-instruction()">
+      <xsl:param name="indent" select="'&#xA;'"/>
+      <xsl:value-of select="$indent"/>
+      <xsl:copy />
+   </xsl:template>
+
+   <!-- WARNING: this is dangerous. Handle with care -->
+   <xsl:template match="text()[normalize-space(.)='']"/>
+
+</xsl:stylesheet>