- From: J. David Eisenberg <catcode@catcode.com>
- Date: Sun, 8 Dec 2002 18:55:21 -0600 (CST)
- To: Hyunju Shim <hshim@cise.ufl.edu>
- cc: www-svg@w3.org
On Sun, 8 Dec 2002, J. David Eisenberg wrote:
Oops. Didn't do a search-and-replace on enough lines.
The variable "onespec" should be changed to
"attrValPair" everywhere. The corrected version is below.
Also note that the first template doesn't copy any comment nodes.
==============================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes" />
<!--
This template taken from XSLT, by Doug Tidwell, published by
O'Reilly & Associates
-->
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name()='style'">
<xsl:call-template name="expand-style">
<xsl:with-param name="stylestr" select="."/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="{name()}"><xsl:value-of
select="."/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:apply-templates select="*|text()"/>
</xsl:element>
</xsl:template>
<!--
Here's the template that splits out the style.
Written by JDEisenberg
-->
<xsl:template name="expand-style">
<xsl:param name="stylestr"/>
<xsl:if test="contains($stylestr,';') or
normalize-space($stylestr) !=''">
<xsl:variable name="attrValPair" select="substring-before($stylestr,';')"/>
<xsl:variable name="attr"
select="normalize-space(substring-before($attrValPair,':'))"/>
<xsl:variable name="value"
select="normalize-space(substring-after($attrValPair,':'))"/>
<xsl:attribute name="{$attr}"><xsl:value-of
select="$value"/></xsl:attribute>
<xsl:call-template name="expand-style">
<xsl:with-param name="stylestr"
select="substring-after($stylestr,';')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
==============================================================
--
J. David Eisenberg http://catcode.com/
Received on Sunday, 8 December 2002 19:58:07 UTC