[Mono-list] XSLT Problems

Richard Polton Richard.Polton@morganstanley.com
Wed, 09 Jul 2003 09:25:42 +0100


Isn't the namespace definition supposed to be included on the <?xml ... >=
 line? I always insert

xmlns:xsl=3D'http://www.w3.org/1999/XSL/Transform'

to my stylesheets.

Ivan Hawkes wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ok, I've Googled until my eyes bugged out of my head but no answer to t=
his
> one...
>
> I have some XML and an XSL file to transform that into some HTML output=
=2E Deep
> within the program I am converting is a call to transform the XML using=
 the
> XSL file provided. If I perform the transform from the command line wit=
h
> xsltproc then it all works, but the code using C# fails. Output is belo=
w:
>
> [ivan@hal9000 simpletest]$ mono simpletest.exe
> =EF=BB=BFStarting up
> Path=3D/home/ivan/simpletest/Stylesheets
> Entity: line 1: warning: Namespace prefix xsl is not defined
> <?xml version=3D"1.0" encoding=3D"utf-8"?><xsl:stylesheet
> version=3D"1.0"><xsl:import
>                                                                   ^
> Entity: line 1: warning: Namespace prefix xsl is not defined
> encoding=3D"utf-8"?><xsl:stylesheet version=3D"1.0"><xsl:import
> href=3D"DeepCopy.xsl"
>
> ^
> Entity: line 1: warning: Namespace prefix xsl is not defined
> opy.xsl" /><xsl:output method=3D"xml" version=3D"1.0" encoding=3D"UTF-8=
"
> indent=3D"yes"
>
> ^
> Entity: line 1: warning: Namespace prefix xsl is not defined
> xml" version=3D"1.0" encoding=3D"UTF-8" indent=3D"yes" /><xsl:template
> match=3D"content
>
> ^
> Entity: line 1: warning: Namespace prefix xsl is not defined
> :value-of select=3D"normalize-space
> (//placeholder[@id=3D'1']/placeholder-content)"
>
> ^
> Entity: line 1: warning: Namespace prefix xsl is not defined
> :value-of select=3D"normalize-space
> (//placeholder[@id=3D'2']/placeholder-content)"
>
> ^
> compilation error: element stylesheet
> xsltParseStylesheetProcess : document is not a stylesheet
>
> Unhandled Exception: System.Xml.XmlException: Error creating stylesheet=

> in <0x000d9> 00 System.Xml.Xsl.XslTransform:GetStylesheetFromString (st=
ring)
> in <0x0006f> 00 System.Xml.Xsl.XslTransform:Load
> (System.Xml.XPath.XPathNavigator)
> in <0x00031> 00 System.Xml.Xsl.XslTransform:Load
> (System.Xml.XPath.IXPathNavigable)
> in <0x00044> 00 Interesource.Util.Xslt.XsltHelper:Transform
> (System.Xml.XPath.IXPathNavigable,System.Xml.XPath.IXPathNavigable,Syst=
em.IO.TextWriter,System.Xml.Xsl.XsltArgumentList)
> in <0x0003e> 00 Interesource.Util.Xslt.XsltHelper:Transform
> (System.Xml.XPath.IXPathNavigable,System.Xml.XmlReader,System.IO.TextWr=
iter,System.Xml.Xsl.XsltArgumentList)
> in <0x0008c> 00 Interesource.Publish.Client.ContentElement:Transform
> (System.IO.TextWriter,System.Xml.Xsl.XsltArgumentList,System.Xml.XPath.=
IXPathNavigable)
> in <0x0006d> 00 Interesource.Publish.Client.ContentElement:Transform
> (System.IO.TextWriter,System.Xml.Xsl.XsltArgumentList)
> in <0x00067> 00 Interesource.Publish.Client.ContentElement:Transform
> (System.Xml.Xsl.XsltArgumentList)
> in <0x00022> 00 Interesource.Publish.Client.ContentElement:Transform ()=

> in <0x000d9> 00 simpletest.SimpleTest:Main (string[])
>
> The transform routine looks like the following:
>
>                 /// <summary>
>                 /// Transforms the instance doucment using the provided=
 stylesheet.
>                 /// </summary>
>                 /// <param name=3D"stylesheet">The stylesheet to use.</=
param>
>                 /// <param name=3D"instanceDoc">An <see cref=3D"IXPathN=
avigable"/> over the XML
> data to transform.</param>
>                 /// <param name=3D"output">The output stream to write t=
o.</param>
>                 public static void Transform(IXPathNavigable stylesheet=
, IXPathNavigable
> instanceDoc, TextWriter output, XsltArgumentList args)
>                 {
>                         XslTransform x =3D new XslTransform();
>                         x.Load(stylesheet);
>
>                         XmlTextWriter writer =3D new XmlTextWriter(outp=
ut);
>                         writer.Formatting =3D Formatting.None;
>
>                         x.Transform(instanceDoc, args, writer);
>                 }
>
> Now, for some reason, the Load function isn't happy with the XSL file, =
even
> though from the output provided you can see that it has loaded the corr=
ect
> file.
>
> Any clues?
>
> My Setup:
>         OS RedHat 9.0 (Shrike - stock)
>         Mono/MCS built from CVS today
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iQIVAwUBPwXgcfr1e7bH1pzBAQJ6thAAjXLA47kmelf96fA3c2tQKrdatyfV36YS
> lS6Y6DOQZSeYowkopUp3twPPDhl7XsP1SHfan6xllD41hRKlQCUQYPYY1lJ+XqTw
> VWQKl1DQetxd+qcAzo6CSA4P7eq7lEtq1DJ/Uj5+cyjkwmS8qPM7AkA2YovHitxO
> II2UPE+n2ZIttSCkFMU+RudXzZeQ5jTYh1ekD25KVOW5M4l6fTVgsLQQzmtvX2DB
> QvDU4FVpI+Fjdn4f4S2437tEq0oKVYstxah8LflMe8fPtz0TYInv00eZvutFYzGl
> xhAODbDZobISBhtTwjer2ea0If0VBEHutb5WlEANYZGyDLYPHE0ajqQtcAid06+O
> 3zmn5FURCuOlXzFxJ2ABA90PFAciUpMD3vUO/pvohIpWsxf4jranm0eTIHahncs2
> 0XffszRXPd0HHkynwlSOxmMvn0AapOpTYO7GjqKPzzL1bsIH86q6mhM4hfocUvS8
> 4dB3wmgijre8fLo9aiQbgPZvua8zsUZU8D3D9pR/KwVqq5IsHJJeBqApOGsfOcmZ
> VIuiz0rVfkUtYgNeVVbbArtojkOi5ziwMs0+la+IyHQ9Ut+YLM0pM0PjJVSBYdky
> HD1f9AuyxATmx0xARrxNsq1pOgGFW3bwm4TBfNoY9qGikGMG3NylW5yYfP7YGrS4
> r+FASb9Fgv8=3D
> =3DQ0EE
> -----END PGP SIGNATURE-----
>
>   ---------------------------------------------------------------------=
---
>                    Name: DeepCopy.xsl
>    DeepCopy.xsl    Type: Web Service Discovery File (text/xml)
>                Encoding: quoted-printable
>
>                 Name: notes.xsl
>    notes.xsl    Type: Web Service Discovery File (text/xml)
>             Encoding: 7bit
>
>                Name: test.xml
>    test.xml    Type: Web Service Discovery File (text/xml)
>            Encoding: 7bit

--
NOTICE: If received in error, please destroy and notify sender.  Sender d=
oes not waive confidentiality or privilege, and use
is prohibited.