xsl-list
[Top] [All Lists]

RE: Copying an entire NodeSet with modified selected attribute values

2005-06-23 08:48:02
Try this:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:param name="new-height" select="'50%'" />

  <xsl:template match="/">
    <xsl:apply-templates><xsl:with-param name="new-height" 
/></xsl:apply-templates>
  </xsl:template>

  <xsl:template match="svg">
    <xsl:copy>
      <xsl:for-each select="@*">
        <xsl:choose>
          <xsl:when test="name()='height'">
            <xsl:attribute name="height"><xsl:value-of select="$new-height" 
/></xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:copy />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="g">
    <xsl:copy-of select="." />
  </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     <michella(_at_)post(_dot_)ch>
Sent:     Thu, 23 Jun 2005 17:21:51 +0200
To:       <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  [xsl] Copying an entire NodeSet with modified selected attribute 
values

Hi all,

A need a little help :

Given SVG:

<svg width="100%" height="100%" viewBox="-24 -21 1296 1135"
preserveAspectRatio="xMinYMin meet" kerning="0" xml:space="preserve"
xmlns:xlink="http://www.w3.org/1999/xlink"; style="stroke: black; fill:
none;">
        <g id="122" type="443" node="Yes">
        ...
        </g>
</svg>

I would like to keep/copy the entire SVG Structure, but just change
specific attribute values.

Example :clone it, except that : (...) height="NEWVALUE" (...)

Could it be possible to simple use xsl:copy-of function with exceptions
(IFs)?

Thanks for your replies ;-)

Lawrence Michel

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • RE: Copying an entire NodeSet with modified selected attribute values, cknell <=