473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 advancedOptionsFile 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;

XmlNamespaceManager nsmgr = XmlaWrapper.ReturnXmlaNameSpaceManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXml(Utilities.GetResource("ZapOLAP.xs ltMDXtoHTMLAdvanced.xslt")
);

XslTransform xslt = new XslTransform();

xslt.Load(xsltHTML.DocumentElement.CreateNavigator (), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentList xslArg = new XsltArgumentList();

xslArg.AddParam("varAdvanced", "", "document('" + advancedOptionsFile +
"')");

using(StringWriter writer = new StringWriter())

{

xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), 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 1995
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.DocumentElement.Creat eNavigator(), xslArg,
writer, null);
to
xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), xslArg,
writer, new XmlUrlResolver());

-Naraen

----
"Cathie" <so*****@miscrosoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.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 advancedOptionsFile 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;

XmlNamespaceManager nsmgr = XmlaWrapper.ReturnXmlaNameSpaceManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXml(Utilities.GetResource("ZapOLAP.xs ltMDXtoHTMLAdvanced.xslt") );

XslTransform xslt = new XslTransform();

xslt.Load(xsltHTML.DocumentElement.CreateNavigator (), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentList xslArg = new XsltArgumentList();

xslArg.AddParam("varAdvanced", "", "document('" + advancedOptionsFile +
"')");

using(StringWriter writer = new StringWriter())

{

xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), 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
"NaraendiraKumar R. R." <na********@nospam.com> wrote in message
news:ui**************@TK2MSFTNGP12.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.DocumentElement.Creat eNavigator(), xslArg,
writer, null);
to
xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), xslArg,
writer, new XmlUrlResolver());

-Naraen

----
"Cathie" <so*****@miscrosoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.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 advancedOptionsFile 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;

XmlNamespaceManager nsmgr = XmlaWrapper.ReturnXmlaNameSpaceManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXml(Utilities.GetResource("ZapOLAP.xs ltMDXtoHTMLAdvanced.xslt")
);

XslTransform xslt = new XslTransform();

xslt.Load(xsltHTML.DocumentElement.CreateNavigator (), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentList xslArg = new XsltArgumentList();

xslArg.AddParam("varAdvanced", "", "document('" + advancedOptionsFile +
"')");

using(StringWriter writer = new StringWriter())

{

xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), 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(xsltHTML.DocumentElement.CreateNavigator (), null, null);

Try change it to
xslt.Load(xsltHTML.DocumentElement.CreateNavigator (), new XmlUrlResolver(),
this.GetType().Assembly.Evidence);

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("varAdvanced", "", advancedOptionsFile);

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

<xsl:apply-templates match="/">
<xsl:for-each select="document($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*****@miscrosoft.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Thanks for your response. It still doesn't work. Any other ideas?

Cathie
"NaraendiraKumar R. R." <na********@nospam.com> wrote in message
news:ui**************@TK2MSFTNGP12.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.DocumentElement.Creat eNavigator(), xslArg,
writer, null);
to
xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), xslArg,
writer, new XmlUrlResolver());

-Naraen

----
"Cathie" <so*****@miscrosoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.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 advancedOptionsFile 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;

XmlNamespaceManager nsmgr = XmlaWrapper.ReturnXmlaNameSpaceManager();

// Retrieve the XSLT to transform

XmlDocument xsltHTML = new XmlDocument();

xsltHTML.LoadXml(Utilities.GetResource("ZapOLAP.xs ltMDXtoHTMLAdvanced.xslt") );

XslTransform xslt = new XslTransform();

xslt.Load(xsltHTML.DocumentElement.CreateNavigator (), null, null);

// Add the Advanced Formatting XML document as a parameter

XsltArgumentList xslArg = new XsltArgumentList();

xslArg.AddParam("varAdvanced", "", "document('" + advancedOptionsFile + "')");

using(StringWriter writer = new StringWriter())

{

xslt.Transform(xmlSimplified.DocumentElement.Creat eNavigator(), 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("varAdvanced", "", "document('" + advancedOptionsFile +
"')");


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 XPathNodIterator.

--
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
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...
2
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 =...
5
by: Daniel Crespo | last post by:
Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"? Thanks
4
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...
5
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...
5
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...
1
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...
1
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
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 ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.