471,594 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

XSLT, coming from ASP model

Hello,

I am moving over from using msxml2.domdocument to system.xml and
system.xml.xsl.

I'd like to present this to my group today, so your help is appreciated.

I want to transform an XML object (built on the fly) with an XSL document
(URL to document) and have it return a string object for my function.

Here's where I am:

Function x as String
'this function will return transformed xml
Dim oXML as New System.xml.xmldocument
oXML.LoadXML("<document/>")

oXSL as New System.xml.xmldocument
oXSL.Load([stylesheet])

x = ???
End Function

I started down the path of creating an XMLReader class, and I was going to
"read" that into x. Am I on the right track?

Your help is appreciated,

Eric
Nov 12 '05 #1
8 2043
Eric Phetteplace wrote:
I am moving over from using msxml2.domdocument to system.xml and
system.xml.xsl.

I'd like to present this to my group today, so your help is appreciated.

I want to transform an XML object (built on the fly) with an XSL document
(URL to document) and have it return a string object for my function.

Here's where I am:

Function x as String
'this function will return transformed xml
Dim oXML as New System.xml.xmldocument
oXML.LoadXML("<document/>")

oXSL as New System.xml.xmldocument
oXSL.Load([stylesheet])

x = ???
End Function


No, that's MSXML model. In .NET you better use the following (C# code):

XmlDocument doc = new XmlDocument();
//Build it
doc.LoadXml("<doc/>");
XslTransform xslt = new XslTransform();
//Load stylesheet (you should use here Server.MapPath in ASP.NET)
xslt.Load("whatever.xsl");
StringWriter sw = new StringWriter();
//Run transformation
xslt.Transform(doc, null, sw, null);
sw.Close();
return sw.ToString()

Additionally consider caching compiled XslTransform object for
repetitive transformations.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Eric Phetteplace wrote:
I am moving over from using msxml2.domdocument to system.xml and
system.xml.xsl.

I'd like to present this to my group today, so your help is appreciated.

I want to transform an XML object (built on the fly) with an XSL document
(URL to document) and have it return a string object for my function.

Here's where I am:

Function x as String
'this function will return transformed xml
Dim oXML as New System.xml.xmldocument
oXML.LoadXML("<document/>")

oXSL as New System.xml.xmldocument
oXSL.Load([stylesheet])

x = ???
End Function


No, that's MSXML model. In .NET you better use the following (C# code):

XmlDocument doc = new XmlDocument();
//Build it
doc.LoadXml("<doc/>");
XslTransform xslt = new XslTransform();
//Load stylesheet (you should use here Server.MapPath in ASP.NET)
xslt.Load("whatever.xsl");
StringWriter sw = new StringWriter();
//Run transformation
xslt.Transform(doc, null, sw, null);
sw.Close();
return sw.ToString()

Additionally consider caching compiled XslTransform object for
repetitive transformations.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3
Thanks Oleg, that's what I needed.

However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method. I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.

Perhaps it doesn't recognize my null? System.DBNull didn't help. Perhaps
it's the XMLDocument?

Eric
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
Eric Phetteplace wrote:
I am moving over from using msxml2.domdocument to system.xml and
system.xml.xsl.

I'd like to present this to my group today, so your help is appreciated.

I want to transform an XML object (built on the fly) with an XSL document (URL to document) and have it return a string object for my function.

Here's where I am:

Function x as String
'this function will return transformed xml
Dim oXML as New System.xml.xmldocument
oXML.LoadXML("<document/>")

oXSL as New System.xml.xmldocument
oXSL.Load([stylesheet])

x = ???
End Function


No, that's MSXML model. In .NET you better use the following (C# code):

XmlDocument doc = new XmlDocument();
//Build it
doc.LoadXml("<doc/>");
XslTransform xslt = new XslTransform();
//Load stylesheet (you should use here Server.MapPath in ASP.NET)
xslt.Load("whatever.xsl");
StringWriter sw = new StringWriter();
//Run transformation
xslt.Transform(doc, null, sw, null);
sw.Close();
return sw.ToString()

Additionally consider caching compiled XslTransform object for
repetitive transformations.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #4
Thanks Oleg, that's what I needed.

However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method. I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.

Perhaps it doesn't recognize my null? System.DBNull didn't help. Perhaps
it's the XMLDocument?

Eric
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
Eric Phetteplace wrote:
I am moving over from using msxml2.domdocument to system.xml and
system.xml.xsl.

I'd like to present this to my group today, so your help is appreciated.

I want to transform an XML object (built on the fly) with an XSL document (URL to document) and have it return a string object for my function.

Here's where I am:

Function x as String
'this function will return transformed xml
Dim oXML as New System.xml.xmldocument
oXML.LoadXML("<document/>")

oXSL as New System.xml.xmldocument
oXSL.Load([stylesheet])

x = ???
End Function


No, that's MSXML model. In .NET you better use the following (C# code):

XmlDocument doc = new XmlDocument();
//Build it
doc.LoadXml("<doc/>");
XslTransform xslt = new XslTransform();
//Load stylesheet (you should use here Server.MapPath in ASP.NET)
xslt.Load("whatever.xsl");
StringWriter sw = new StringWriter();
//Run transformation
xslt.Transform(doc, null, sw, null);
sw.Close();
return sw.ToString()

Additionally consider caching compiled XslTransform object for
repetitive transformations.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #5
Eric Phetteplace wrote:
However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method.
Hmm. Which .NET version are you using? There is a difference in
XslTransform API between .NET 1.0 and 1.1. I meant the following method:

[Visual Basic] Overloads Public Sub Transform(IXPathNavigable,
XsltArgumentList, TextWriter, XmlResolver)
[C#] public void Transform(IXPathNavigable, XsltArgumentList,
TextWriter, XmlResolver);

XmlDocument is IXPathNavigable and StringWriter is TextWriter.
I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.


It's Nothing as far as I know. in VB.NET you should have something like

xslt.Transform(doc, Nothing, sw, Nothing)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6
Eric Phetteplace wrote:
However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method.
Hmm. Which .NET version are you using? There is a difference in
XslTransform API between .NET 1.0 and 1.1. I meant the following method:

[Visual Basic] Overloads Public Sub Transform(IXPathNavigable,
XsltArgumentList, TextWriter, XmlResolver)
[C#] public void Transform(IXPathNavigable, XsltArgumentList,
TextWriter, XmlResolver);

XmlDocument is IXPathNavigable and StringWriter is TextWriter.
I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.


It's Nothing as far as I know. in VB.NET you should have something like

xslt.Transform(doc, Nothing, sw, Nothing)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #7
Using 'Nothing' in place of 'null' solved the problem.

Thanks again Oleg. You've been most helpful.

Regards,

Eric Phetteplace

"Oleg Tkachenko [MVP]" <oleg@no_!spam!_please!tkachenko.com> wrote in
message news:OY**************@TK2MSFTNGP10.phx.gbl...
Eric Phetteplace wrote:
However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method.


Hmm. Which .NET version are you using? There is a difference in
XslTransform API between .NET 1.0 and 1.1. I meant the following method:

[Visual Basic] Overloads Public Sub Transform(IXPathNavigable,
XsltArgumentList, TextWriter, XmlResolver)
[C#] public void Transform(IXPathNavigable, XsltArgumentList,
TextWriter, XmlResolver);

XmlDocument is IXPathNavigable and StringWriter is TextWriter.
I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.


It's Nothing as far as I know. in VB.NET you should have something like

xslt.Transform(doc, Nothing, sw, Nothing)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #8
Using 'Nothing' in place of 'null' solved the problem.

Thanks again Oleg. You've been most helpful.

Regards,

Eric Phetteplace

"Oleg Tkachenko [MVP]" <oleg@no_!spam!_please!tkachenko.com> wrote in
message news:OY**************@TK2MSFTNGP10.phx.gbl...
Eric Phetteplace wrote:
However, when I try to compile, (forgive the paraphrasing, as I'm not in
front of my .NET machine) I get an error saying there isn't a Transform
method with these parameter types. There are 18 definitions of the
Transform method.


Hmm. Which .NET version are you using? There is a difference in
XslTransform API between .NET 1.0 and 1.1. I meant the following method:

[Visual Basic] Overloads Public Sub Transform(IXPathNavigable,
XsltArgumentList, TextWriter, XmlResolver)
[C#] public void Transform(IXPathNavigable, XsltArgumentList,
TextWriter, XmlResolver);

XmlDocument is IXPathNavigable and StringWriter is TextWriter.
I had to use chr(0) in place of the NULL keyword, since
there is no NULL in VB.NET.


It's Nothing as far as I know. in VB.NET you should have something like

xslt.Transform(doc, Nothing, sw, Nothing)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Christian Roth | last post: by
2 posts views Thread by Tom Corcoran | last post: by
9 posts views Thread by Jeff Rubard | last post: by
5 posts views Thread by Fred | last post: by
6 posts views Thread by Prashanth Ellina | last post: by
2 posts views Thread by seeCoolGuy | last post: by
3 posts views Thread by Ian Roddis | last post: by
reply views Thread by poli | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.