[Mono-list] XSLT Problems

Richard Polton Richard.Polton@morganstanley.com
Wed, 09 Jul 2003 09:33:03 +0100


Uh, in the opening <xsl:stylesheet ... > tag is what I meant ... Doh!

Richard Polton wrote:

> 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=
 this
> > one...
> >
> > I have some XML and an XSL file to transform that into some HTML outp=
ut. Deep
> > within the program I am converting is a call to transform the XML usi=
ng the
> > XSL file provided. If I perform the transform from the command line w=
ith
> > xsltproc then it all works, but the code using C# fails. Output is be=
low:
> >
> > [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:templat=
e
> > 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 styleshe=
et
> > in <0x000d9> 00 System.Xml.Xsl.XslTransform:GetStylesheetFromString (=
string)
> > 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,Sy=
stem.IO.TextWriter,System.Xml.Xsl.XsltArgumentList)
> > in <0x0003e> 00 Interesource.Util.Xslt.XsltHelper:Transform
> > (System.Xml.XPath.IXPathNavigable,System.Xml.XmlReader,System.IO.Text=
Writer,System.Xml.Xsl.XsltArgumentList)
> > in <0x0008c> 00 Interesource.Publish.Client.ContentElement:Transform
> > (System.IO.TextWriter,System.Xml.Xsl.XsltArgumentList,System.Xml.XPat=
h.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 provid=
ed stylesheet.
> >                 /// </summary>
> >                 /// <param name=3D"stylesheet">The stylesheet to use.=
</param>
> >                 /// <param name=3D"instanceDoc">An <see cref=3D"IXPat=
hNavigable"/> over the XML
> > data to transform.</param>
> >                 /// <param name=3D"output">The output stream to write=
 to.</param>
> >                 public static void Transform(IXPathNavigable styleshe=
et, IXPathNavigable
> > instanceDoc, TextWriter output, XsltArgumentList args)
> >                 {
> >                         XslTransform x =3D new XslTransform();
> >                         x.Load(stylesheet);
> >
> >                         XmlTextWriter writer =3D new XmlTextWriter(ou=
tput);
> >                         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 co=
rrect
> > 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=
 does not waive confidentiality or privilege, and use
> is prohibited.
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

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