473,506 Members | 16,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

It's gotta be something real obvious: Transform with param

I have this xslt :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="p" select="'q'"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<xsl:element name="test">
<xsl:value-of select="$p"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

and this method:

[WebMethod]
public XmlDocument Xsltest (String para)
{
XmlDocument tmp_xdoc = new XmlDocument();
XmlReader xmlrdr;
XsltArgumentList xslArg = new XsltArgumentList();
XslTransform xslt = new XslTransform();

try{
xslArg.AddParam("p", "", para);
xslt.Load(Server.MapPath("DescribeTypeTransform2.x slt"));
//data_xdoc exists already as global scope XmlDocument
xmlrdr = xslt.Transform(data_xdoc, xslArg);
tmp_xdoc.Load(xmlrdr);
}
catch (Exception e){
String s = "<error>" + e.Message + "</error>";
tmp_xdoc.LoadXml(s);
}

return tmp_xdoc;

}//end DocumentFeatureType

What I expected to see was

<?xml version="1.0" encoding="utf-8" ?>
<test>[the value of para as passed to the method or 'q']</test>

Instead I get

<?xml version="1.0" encoding="utf-8" ?>
<test />

But it works as expected in XMLSpy. What gives?
--
GIS&Oracle Developer
Canada and Belgium
Nov 16 '05 #1
1 1422
First, there maybe a leak in your code, which is not your fault, but a
problem with Microsoft...
http://support.microsoft.com/default...EN-US;Q316775&

What you should rather do is this:

//---------------------------------------------
static XmlTransform xslt = null;

[WebMethod]
public XmlDocument XslText ( string para )
{
if ( xslt == null )
{
xslt = new XslTransform();
xslt.Load(Server.MapPath("DescribeTypeTransform2.x slt"));
}

// etc... here
}
//---------------------------------------------
Second, don't expect XslTransform to work the same as every other MsXsl
Transform, because you'll be disappointed. I've had the same problems with
Xsl in the past... looking at your code, the only thing that it may be that
i can think of is the default value select="'q'" in your param
declaration that it "MAY" be struggling with... Otherwise i've tested it and
it looks good.

there's an example on the MSDN that you may want to look at which follows
your syntax.

http://msdn.microsoft.com/library/de...paramtopic.asp
<watch line wraps>

Good luck.

Daniel.
"Dan Beanweed" <Da*********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
I have this xslt :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="p" select="'q'"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<xsl:element name="test">
<xsl:value-of select="$p"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

and this method:

[WebMethod]
public XmlDocument Xsltest (String para)
{
XmlDocument tmp_xdoc = new XmlDocument();
XmlReader xmlrdr;
XsltArgumentList xslArg = new XsltArgumentList();
XslTransform xslt = new XslTransform();

try{
xslArg.AddParam("p", "", para);
xslt.Load(Server.MapPath("DescribeTypeTransform2.x slt"));
//data_xdoc exists already as global scope XmlDocument
xmlrdr = xslt.Transform(data_xdoc, xslArg);
tmp_xdoc.Load(xmlrdr);
}
catch (Exception e){
String s = "<error>" + e.Message + "</error>";
tmp_xdoc.LoadXml(s);
}

return tmp_xdoc;

}//end DocumentFeatureType

What I expected to see was

<?xml version="1.0" encoding="utf-8" ?>
<test>[the value of para as passed to the method or 'q']</test>

Instead I get

<?xml version="1.0" encoding="utf-8" ?>
<test />

But it works as expected in XMLSpy. What gives?
--
GIS&Oracle Developer
Canada and Belgium

Nov 16 '05 #2

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

Similar topics

1
1349
by: Wredniak | last post by:
i have data in xml i want them to display in html (<table>). i can do it, but i don't know how to change <tr bgcolor="..."> i use <xsl:template match="spolka"> <tr>
0
1125
by: John | last post by:
I have a XMl document that needs to transform to string. What I need is to get all of each value from each xml node and separate each value by coma. To do this, I created a XML document and xsl...
5
3103
by: Kenneth | last post by:
Can anyone explain me why it is neccesary to include SqlDbType to the SqlParameter. In every example I see, it is done, but no one explaines why. I have for example a date I want to save into my...
1
1219
by: Daniel | last post by:
Obviously, I'm a newbie to the XSLT lingo, But I was wondering if XLAN or otherwise provides any internal mechanism for setting a param or AVT with the current user.dir from the JVM? Looking from...
1
1923
by: Sonu Kapoor | last post by:
Ok guys, I could bang my head on the laptop, cause I dont get this to work. The scanrio: I am tryting to pass an parameter with the help of XslTransform to the xsl file. But whenever I run the...
12
2876
by: das | last post by:
Hello all, I am using .NET XSLT to transform an XML into another XML file. All this is fine with small files, but when tested with big files (30MB) it is taking between 1hr-2hrs to just transform...
8
1790
by: moralbarometer | last post by:
Hi all, I intend to retrieve the fault node as a a string from the soap message. When i used transform(DOMSource,StreamResult) i get just the <?xml version="1.0" encoding="UTF-8"?> as string. but...
23
2329
by: mike3 | last post by:
Hi. (posted to both newsgroups since I was not sure of which would be appropriate for this question or how specific to the given language it is. If one of them is inappropriate, just don't send...
2
2061
by: everly | last post by:
Hi, I'm helping my friends band and making their MySpace. I messed something up and I can't figure out what it is. Everything is all out of whack on the bottom half of the page. The comments...
0
7103
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
7307
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,...
0
5614
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,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
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...
0
3188
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...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
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...

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.