Reputation: 183
Im trying to create an xsl template of the xaml Line element.
This is what i have so far:
...
<xsl:call-template name="Line">
<xsl:with-param name="xOne" select="70"/>
<xsl:with-param name="xTwo" select="905"/>
<xsl:with-param name="yOne" select="500"/>
<xsl:with-param name="yTwo" select="500"/>
</xsl:call-template>
<xsl:template name="Line">
<xsl:param name="xOne"/>
<xsl:param name="xTwo"/>
<xsl:param name="yOne"/>
<xsl:param name="yTwo"/>
<Line xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Stroke="red"
StrokeThickness="2"
X1="$xOne"
X2="$xTwo"
Y1="<xsl:value-of select="number($yOne)"/>" <!-- example: not working -->
Y2="$yTwo"/>
</xsl:template>
Questions:
<xsl:value-of select="number($xOne)"/>
but thats not possible because of the way I try to implement them.I hope someone with more experience of xslt and xaml could help me? :)
I'm using xsl v1.0
ty in advance.
Upvotes: 1
Views: 1266
Reputation: 24816
Is there a better way to manage those namespaces?
You can add the namespace declarations to the stylesheet root element:
<xsl:stylesheet version="1.0"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
and then use the prefix where required, like:
<xsl:template name="Line">
<!-- ... -->
<x:Line />
</xsl:template>
where prefix is not used, the default namespace will be considered.
The parameters $xOne, $xTwo, ... are not working
Learn about AVT and use:
X1="{$xOne}"
Upvotes: 2
Reputation: 56162
Your can put namespace declaration in root node, i.e.:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
So then you can simply write, without adding namespaces:
<Line
Use {}
to set attribute values, e.g.:
<xsl:template name="Line">
<xsl:param name="xOne"/>
<xsl:param name="xTwo"/>
<xsl:param name="yOne"/>
<xsl:param name="yTwo"/>
<Line
Stroke="red"
StrokeThickness="2"
X1="{$xOne}"
X2="{$xTwo}"
Y1="{$yOne}"
Y2="{$yTwo}"/>
</xsl:template>
Upvotes: 1