473,588 Members | 2,471 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:styleshe et 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;
XsltArgumentLis t xslArg = new XsltArgumentLis t();
XslTransform xslt = new XslTransform();

try{
xslArg.AddParam ("p", "", para);
xslt.Load(Serve r.MapPath("Desc ribeTypeTransfo rm2.xslt"));
//data_xdoc exists already as global scope XmlDocument
xmlrdr = xslt.Transform( data_xdoc, xslArg);
tmp_xdoc.Load(x mlrdr);
}
catch (Exception e){
String s = "<error>" + e.Message + "</error>";
tmp_xdoc.LoadXm l(s);
}

return tmp_xdoc;

}//end DocumentFeature Type

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 1435
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(Serve r.MapPath("Desc ribeTypeTransfo rm2.xslt"));
}

// 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*********@di scussions.micro soft.com> wrote in message
news:09******** *************** ***********@mic rosoft.com...
I have this xslt :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et 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;
XsltArgumentLis t xslArg = new XsltArgumentLis t();
XslTransform xslt = new XslTransform();

try{
xslArg.AddParam ("p", "", para);
xslt.Load(Serve r.MapPath("Desc ribeTypeTransfo rm2.xslt"));
//data_xdoc exists already as global scope XmlDocument
xmlrdr = xslt.Transform( data_xdoc, xslArg);
tmp_xdoc.Load(x mlrdr);
}
catch (Exception e){
String s = "<error>" + e.Message + "</error>";
tmp_xdoc.LoadXm l(s);
}

return tmp_xdoc;

}//end DocumentFeature Type

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
1353
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
1130
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 file. I get results as what I needed if I validate xml document using the xsl file with IE 6.0. However, if I do this in VB.net, I can not get coma or any other charactors to separate value. Any one can help? Here is the XSL code: <?xml...
5
3109
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 Sql Server database through a stored procedure-call. In the database it is defined as a SmallDateTime. Every 3 methods in the client-code below gives the same (and correct) result. So why is it that important? dim param As SqlParameter
1
1220
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 some like: <xsl:param name="location"> <xsl:text>${user.dir}/</xsl:text><xsl:value-of select="$name"/> </xsl:param>
1
1924
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 code, I got the error: System.Xml.XPath.XPathException: Expression must evaluate to a node-set. Maybe somebody can help me out here:
12
2896
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 the file. Here is the code snippet: XPathDocument xdoc = new XPathDocument(fs); XPathNavigator nav = xdoc.CreateNavigator(); xslt.Transform(nav, null, strWriter, null);
8
1799
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 when i use transform(StreamSource,StreamResult) i get the expected String of fault Node. where am i wrong?. transform(DOMSource,StreamResult) and transform(StreamSource,StreamResult) are they different . Does it mean source and result should...
23
2342
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 replies to it.) I'm making a bignum package for use in a program I've got (this is something different from the pi program you may have heard about). The package is going to support manipulating long floating point numbers.
2
2064
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 shouldn't be on the left hand side. Help please! Thanks. ____________________________________________________- <style type="text/css"> { Background Properties } table, tr, td { background-color:transparent; border:none; border-width:0;} body {...
0
8228
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8357
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6634
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3847
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1196
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.