Rick Tessner wrote:
On Sat, 2005-04-09 at 21:27 +0100, Kevin wrote:
Hi Rick,
I tried the second way and all child elements were copied.
I'll check out the update, thanks.
Hi Kevin,
I've updated this again. There was a bit of a problem with getting the
right, for example, <for:text/> node.
See here for details:
http://svn.apache.org/viewcvs.cgi?rev=160722&view=rev
Thanks Rick that seems to work. Your XPath and recursion
is great.
I have a problem using this method in anger though :( Earlier
in this thread I mentioned implementing a way of generating
group.svg and project.svg using xslt like the corner images.
The resource.xmap code is earlier in this thread.
My real world example skinconf.xml:
...
<group-svg>
<font>28pt</font>
<text-anchor x="0%">start</text-anchor>
</group-svg>
<project-svg>
<font>28pt</font>
<text-anchor x="95%">end</text-anchor>
</project-svg>
...
project.svg.xslt:
...
<xsl:variable name="text-anchor">
<xsl:choose>
<xsl:when test="$config/text-anchor"><xsl:value-of
select="$config/text-anchor"/></xsl:when>
<xsl:otherwise>start</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="text-anchor-x">
<xsl:choose>
<xsl:when test="$config/text-anchor/@x"><xsl:value-of
select="$config/text-anchor/@x"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
...
<xsl:template match="skinconfig">
<svg width="300" height="40">
<title>Logo</title>
<defs>
<linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1">
<stop style="{$fill}" offset="0"/>
<stop style="{$stroke}" offset="0.5"/>
</linearGradient>
...
</defs>
<g filter="url(#shadowFilter)" fill="url(#gradient)">
<text x="{$text-anchor-x}" y="75%" style="font-size:{$font};
font-family:Verdana; text-anchor:{$text-anchor};"><xsl:value-of
select="project-name"/></text>
</g>
</svg>
</xsl:template>
...
So xsl:variables can be assigned and substituted quite easily.
----------------
Now trying the other way using project2text.xsl directly with
project.svg:
...
<defs>
<style type="text/css">
.c1 { stop-color: <for:svg-color1 />; }
.c2 { stop-color: <for:svg-color2 />; }
.t1 { font-size: <for:project-svg><for:font /></for:project-svg>;
font-family:Verdana ; text-anchor: <for:project-svg><for:text-anchor
/></for:project-svg>; }
</style>
...
<linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1">
<stop class="c1" offset="0"/>
<stop class="c2" offset="0.5"/>
</linearGradient>
...
<g filter="url(#shadowFilter)" fill="url(#gradient)">
<text x="95%" y="75%" class="t1" >
<for:project-name />
</text>
...
It gets quite complicated. I couldn't think of a way of
getting @x of <text> without resorting to the way I get
at @value of <color> below. Also I did try and substitute
the whole element. ie.
skinconf.xml:
...
<project-svg>
<text x="95%" y="75%" style="font-size:28pt; font-family:Verdana;
text-anchor:end;">Project</text>
</project-svg>
...
project.svg:
...
<for:project-svg><for:text /></for:project-svg>
Not sure if I'm wrong here but do child attributes get copied across?
----------------------
Anyway I've pasted below other bits I've tried for getting
<color> elements. Though if:
<colors>
<tab-selected>#f00</tab-selected>
<tab-unselected>#00f</tab-unselected>
...
<for:colors><for:tab-selected /></for:colors>
:)
Kevin.
forrest/main/webapp/skins/common/skinconf.xsl:
<xsl:template match="skinconfig">
<xsl:copy>
<xsl:if test="not(svg-color1)">
<xsl:choose>
<xsl:when test="colors/[EMAIL PROTECTED]'tab-unselected']">
<svg-color1><xsl:value-of
select="colors/[EMAIL PROTECTED]'tab-unselected']/@value"/></svg-color1>
</xsl:when>
<xsl:otherwise>
<svg-color1>white</svg-color1>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="not(svg-color2)">
<xsl:choose>
<xsl:when test="colors/[EMAIL PROTECTED]'tab-selected']">
<svg-color2><xsl:value-of
select="colors/[EMAIL PROTECTED]'tab-selected']/@value"/></svg-color2>
</xsl:when>
<xsl:otherwise>
<svg-color2>darkblue</svg-color2>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
...