473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transforming with a variable document

Hi All,

I am trying to get my style sheet to work. It works fine in IE but I can't
get it to work in .net.

Below is the function I use for transforming, where advancedOptions File is
the path to the file containing an XML document required by the
transformation, and xmlSimplified is the XML document to trasform.
----------------------------------------------------------------------------
-------------------------------

string strHTML = String.Empty;

XmlNamespaceMan ager nsmgr = XmlaWrapper.Ret urnXmlaNameSpac eManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXm l(Utilities.Get Resource("ZapOL AP.xsltMDXtoHTM LAdvanced.xslt" )
);

XslTransform xslt = new XslTransform();

xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentLis t xslArg = new XsltArgumentLis t();

xslArg.AddParam ("varAdvance d", "", "document(' " + advancedOptions File +
"')");

using(StringWri ter writer = new StringWriter())

{

xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);

strHTML = writer.ToString ();

}

return strHTML;

----------------------------------------------------------------------------
-------------------------------

If I extract the XSLT and XML (adding a xsl statement to the top of the XML
file) and open my xml file in IE, the results occur as they should, but not
when transforming using the above method. The information from the
advancedOptions file seems to be ignored.

Any ideas in what I am doing wrong?

Thanks in Advance

Cathie
Nov 12 '05 #1
4 2015
You are attempting to use an external document in an XSLT. It is a security
issue.

Try changing this line of code
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);
to
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, new XmlUrlResolver( ));

-Naraen

----
"Cathie" <so*****@miscro soft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi All,

I am trying to get my style sheet to work. It works fine in IE but I can't get it to work in .net.

Below is the function I use for transforming, where advancedOptions File is
the path to the file containing an XML document required by the
transformation, and xmlSimplified is the XML document to trasform.
-------------------------------------------------------------------------- -- -------------------------------

string strHTML = String.Empty;

XmlNamespaceMan ager nsmgr = XmlaWrapper.Ret urnXmlaNameSpac eManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXm l(Utilities.Get Resource("ZapOL AP.xsltMDXtoHTM LAdvanced.xslt" ) );

XslTransform xslt = new XslTransform();

xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentLis t xslArg = new XsltArgumentLis t();

xslArg.AddParam ("varAdvance d", "", "document(' " + advancedOptions File +
"')");

using(StringWri ter writer = new StringWriter())

{

xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);

strHTML = writer.ToString ();

}

return strHTML;

-------------------------------------------------------------------------- -- -------------------------------

If I extract the XSLT and XML (adding a xsl statement to the top of the XML file) and open my xml file in IE, the results occur as they should, but not when transforming using the above method. The information from the
advancedOptions file seems to be ignored.

Any ideas in what I am doing wrong?

Thanks in Advance

Cathie

Nov 12 '05 #2
Thanks for your response. It still doesn't work. Any other ideas?

Cathie
"NaraendiraKuma r R. R." <na********@nos pam.com> wrote in message
news:ui******** ******@TK2MSFTN GP12.phx.gbl...
You are attempting to use an external document in an XSLT. It is a security issue.

Try changing this line of code
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);
to
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, new XmlUrlResolver( ));

-Naraen

----
"Cathie" <so*****@miscro soft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi All,

I am trying to get my style sheet to work. It works fine in IE but I

can't
get it to work in .net.

Below is the function I use for transforming, where advancedOptions File is the path to the file containing an XML document required by the
transformation, and xmlSimplified is the XML document to trasform.


--------------------------------------------------------------------------
--
-------------------------------

string strHTML = String.Empty;

XmlNamespaceMan ager nsmgr = XmlaWrapper.Ret urnXmlaNameSpac eManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXm l(Utilities.Get Resource("ZapOL AP.xsltMDXtoHTM LAdvanced.xslt" )
);

XslTransform xslt = new XslTransform();

xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentLis t xslArg = new XsltArgumentLis t();

xslArg.AddParam ("varAdvance d", "", "document(' " + advancedOptions File +
"')");

using(StringWri ter writer = new StringWriter())

{

xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);

strHTML = writer.ToString ();

}

return strHTML;


--------------------------------------------------------------------------
--
-------------------------------

If I extract the XSLT and XML (adding a xsl statement to the top of the

XML
file) and open my xml file in IE, the results occur as they should, but

not
when transforming using the above method. The information from the
advancedOptions file seems to be ignored.

Any ideas in what I am doing wrong?

Thanks in Advance

Cathie


Nov 12 '05 #3
Hmmm ...
a ) This line does'nt have any resolver or evidence either.
xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), null, null);

Try change it to
xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), new XmlUrlResolver( ),
this.GetType(). Assembly.Eviden ce);

Suggest you read up on the Evidence section of the load method to decide
which evidence method is right for your application.

b) I'm curious about your XSLT. I don't think passing document() as a
parameter value will yield what you are looking for. The only way I have
been successful, is to pass only the filename as the parameter. Then in
the XSLT you can pass the paramter variable to the document function, to
yeild a node-set.

E.g.
Changing the AddParam line to below ...
xslArg.AddParam ("varAdvance d", "", advancedOptions File);

In the XSLT doing ...
....
<xsl:param name="varAdvanc ed"/>

<xsl:apply-templates match="/">
<xsl:for-each select="documen t($varAdvanced) ">
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:apply-templates>
....

If you success in passing parameter any other way, please share it with the
group. I will be interested in learning from your experience.

Hope this helps,
-Naraen
---
"Cathie" <so*****@miscro soft.com> wrote in message
news:%2******** *********@tk2ms ftngp13.phx.gbl ...
Thanks for your response. It still doesn't work. Any other ideas?

Cathie
"NaraendiraKuma r R. R." <na********@nos pam.com> wrote in message
news:ui******** ******@TK2MSFTN GP12.phx.gbl...
You are attempting to use an external document in an XSLT. It is a security
issue.

Try changing this line of code
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, null);
to
xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg,
writer, new XmlUrlResolver( ));

-Naraen

----
"Cathie" <so*****@miscro soft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi All,

I am trying to get my style sheet to work. It works fine in IE but I

can't
get it to work in .net.

Below is the function I use for transforming, where advancedOptions File is
the path to the file containing an XML document required by the
transformation, and xmlSimplified is the XML document to trasform.


--------------------------------------------------------------------------
--
-------------------------------

string strHTML = String.Empty;

XmlNamespaceMan ager nsmgr = XmlaWrapper.Ret urnXmlaNameSpac eManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXm l(Utilities.Get Resource("ZapOL AP.xsltMDXtoHTM LAdvanced.xslt" ) );

XslTransform xslt = new XslTransform();

xslt.Load(xsltH TML.DocumentEle ment.CreateNavi gator(), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentLis t xslArg = new XsltArgumentLis t();

xslArg.AddParam ("varAdvance d", "", "document(' " + advancedOptions File + "')");

using(StringWri ter writer = new StringWriter())

{

xslt.Transform( xmlSimplified.D ocumentElement. CreateNavigator (), xslArg, writer, null);

strHTML = writer.ToString ();

}

return strHTML;


--------------------------------------------------------------------------
--
-------------------------------

If I extract the XSLT and XML (adding a xsl statement to the top of
the XML
file) and open my xml file in IE, the results occur as they should,
but not
when transforming using the above method. The information from the
advancedOptions file seems to be ignored.

Any ideas in what I am doing wrong?

Thanks in Advance

Cathie



Nov 12 '05 #4
Cathie wrote:
xslArg.AddParam ("varAdvance d", "", "document(' " + advancedOptions File +
"')");


That won't work. You are effectively passing string, containing
"document() ". Just a string. To pass another document to XSLT, load it
into XPathDocument and pass root node as XPathNodIterato r.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4114
by: David Furey | last post by:
Hi, I am using the XSLT document to filter records from an XML document The XSL is shown below: I have a parameter named "search-for" that is used to bring back a list of Vendor Names that start with this parameter. The list works as I want for alpabetical letters. Setting the parameter to 'a' brings back a list of vendors beginning
2
1793
by: Mirjana Rakuljic | last post by:
Hi, I need help with transforming XML document. I generate xml document from query using Oracle XSU (DBMS_XMLQUERY) and the document I get is like this: <?xml version = '1.0' encoding = 'ISO-8859-1'?> <MultiPAT> <PAT> <numreferencia>000000000000</numreferencia>
5
1756
by: Daniel Crespo | last post by:
Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"? Thanks
4
1922
by: Showjumper | last post by:
I am using the NITF DTD for my xml files and i need to use 2 xsl files to do the transform: one for the <body.head> and the second for the <body.content>. I've got this so far for transforming using 1 xsl file: Dim doc As New XmlDocument doc.LoadXml(xmlText) Dim xslDoc As New XslTransform xslDoc.Load(xslpath) Dim sw As New StringWriter...
5
4492
by: Jiho Han | last post by:
I do a transform of an xml document into another xml using XslTransform. In my xsl file, I specify using <xsl:output encoding="utf-8"/>. However, when my transform is done, the resulting xml is in utf-16. What gives? Anyone?
5
6180
by: Gustaf | last post by:
I've been trying to update my code to the new XslCompiledTransform class without success. The following method takes an XML and XSL file, and returns an XmlDocument object. Can anyone figure out how to write the parameters to the XslCompiledTransform.Transform() method in this case? static XmlDocument Transform(string xml, string xsl) {...
1
2417
by: MaggotChild | last post by:
Hi, I'm trying to transform the values entered into a form: HTML: <div id="container"> <div id="bs"> <input id="name" type="text"/> <p>PPPPP</p> <a href="#" onclick="return transform()">Do it!</a> </div>
1
2060
by: scmorgan | last post by:
Hi All, I am trying to come up with a solution for transforming a complex type ie xml ... <document> <label> This is a <highlight> string</highlight> </label>
10
10335
by: Mauro | last post by:
I'm trying to use the following VB function to transform a pdf document to a tiff one: http://forums.microsoft.com/msdn/showpost.aspx?postid=1665127&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1 Private Sub savePDFtoTIF(ByVal fullPathPDF As String, ByVal fullPathTIF As String) Dim PDFApp As Acrobat.AcroApp Dim PDDoc As Acrobat.CAcroPDDoc Dim...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.