4 using System.Xml.XPath;
7 namespace MonoTests.System.Xml.Xsl
10 public class XslCompiledTransformTests
13 public void GlobalVariableReferencesAnotherGlobalVariable ()
15 string xsl = @"<xsl:stylesheet version='1.0'
16 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
17 <xsl:variable name='global2'><xsl:value-of select='root/@attr' /></xsl:variable>
18 <xsl:variable name='global1'>
19 <xsl:for-each select='//foo'>
20 <xsl:if test='@attr = $global2'>
21 <xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
25 <xsl:template match='/'>
27 <xsl:value-of select='$global1' />
31 StringWriter sw = new StringWriter ();
32 XslCompiledTransform t = new XslCompiledTransform ();
33 t.Load (new XPathDocument (new StringReader (xsl)));
34 t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root attr='B'><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
35 Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><root>foo: B</root>", sw.ToString ());