sybe
asked on
Get XSL-string back from XslCompiledTransform
Since I seem to be asking question that are hard to answer, here is another one.
It is easy to create an XslCompiledTransform from a file.
Dim oXSL As New XslCompiledTransform()
oXSL.Load("c:\temp\file.xs l")
The question is: can I get the XSL-string back from the XslCompiledTransform object. Or do I need to read the file from disk again?
It is easy to create an XslCompiledTransform from a file.
Dim oXSL As New XslCompiledTransform()
oXSL.Load("c:\temp\file.xs
The question is: can I get the XSL-string back from the XslCompiledTransform object. Or do I need to read the file from disk again?
ASKER
Because there seems no way to get the XSL string back from the XslCompiledTransform, that is what I am doing now.
More or less that is, I skip the XmlTextReader, because XmlDocument can read from disk directly:
Dim oXML As New XmlDocument()
oXML.Load("C:\temp\file.xs l")
Interestingly enough you are using an undocumented method
XslCompiledTransform.Load( ) is not documented to take XMLDocument as parameter, but it works anyway.
http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.load.aspx
More or less that is, I skip the XmlTextReader, because XmlDocument can read from disk directly:
Dim oXML As New XmlDocument()
oXML.Load("C:\temp\file.xs
Interestingly enough you are using an undocumented method
XslCompiledTransform.Load(
http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.load.aspx
> because XmlDocument can read from disk directly:
What do you mean with "directly"? It internally uses the XmlTextReader. See snippet from XmlDocument's code below. Meaning, you can skip it, but you won't because it is used anyway (which means: skipping is the easier way to code, of course).
> Interestingly enough you are using an undocumented method
Not really ;-) It is documented here: http://msdn.microsoft.com/en-us/library/ms163422.aspx
What do you mean with "directly"? It internally uses the XmlTextReader. See snippet from XmlDocument's code below. Meaning, you can skip it, but you won't because it is used anyway (which means: skipping is the easier way to code, of course).
> Interestingly enough you are using an undocumented method
Not really ;-) It is documented here: http://msdn.microsoft.com/en-us/library/ms163422.aspx
public virtual void Load(string filename)
{
XmlTextReader reader = this.SetupReader(new XmlTextReader(filename, this.NameTable));
try
{
this.Load(reader);
}
finally
{
reader.Close();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, I wanted to do that because I need to adapt the XSL after loading it. It is really nice that XslCompiledTransform is fast, but it is also quite frigid. So it should be used only after adapting the XSL.
Concerning your earlier remarks about skipping XmlReader and XmlDocument as parameter for XslCompiledTransform.Load( )
I see. You are right.
Anyway, you earn all credits for explaining. Thanks.
Concerning your earlier remarks about skipping XmlReader and XmlDocument as parameter for XslCompiledTransform.Load(
I see. You are right.
Anyway, you earn all credits for explaining. Thanks.
ASKER
Thanks!
> but it is also quite frigid
very much so indeed. You can always write your own wrapper to make it a bit easier to do all these things, and just set some properties the way you want it, including the URI to your XSLT file. Then you simply make one Transform method, which applies these settings and runs the transform.
But I'm sure you know how to do that ;-)
tx for the grade and the follow-up!
very much so indeed. You can always write your own wrapper to make it a bit easier to do all these things, and just set some properties the way you want it, including the URI to your XSLT file. Then you simply make one Transform method, which applies these settings and runs the transform.
But I'm sure you know how to do that ;-)
tx for the grade and the follow-up!
Open in new window