473,782 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL Transform Problem using Xml.XSL.Transfo rm

I have an interesting problem. I am performing an XSL
transform using the System.Xml.Xsl. Transform class.
I have a database that contains the XSL style sheet
string. And it seems to work pretty well for simple
transforms. But as soon as I add Xsl variables or For each
loops to the XSL string in the db, it fails to transform
the XML. I can see that it will transform everything until
that point. ALso If I copy the XSL & XML I am trying to
transform from my watch window into a file.. It works
perfectly. Any Ideas?
The following is the C# code I am using to transform & the
XSL I am using to transform.

//Code
XmlDocument transform = new XmlDocument();
transform.LoadX ml(DataFormat); //DataFormat xsl string

XmlUrlResolver resolver = new XmlUrlResolver( );
XslTransform xslTran = new XslTransform();
xslTran.Load(tr ansform,resolve r,null);

XmlReader reader =
xslTran.Transfo rm(XmlData,null ,resolver);
reader.MoveToCo ntent();
string readerOutput = reader.ReadOute rXml();

//XSL
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="DataSour ce">
<B>Report</B><BR/>
<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
<TR><TH>Agreeme nt Number</TH>
<TH>Name</TH>
<TH>Period</TH>
<TH>Due Date</TH>
<TH>Type</TH>
</TR>
<xsl:for-each select="tblRepo rt[code='XYZ']">
<TR>
<TD><xsl:valu e-of select="Agreeme ntNumber"/></TD>
<TD><xsl:valu e-of select="Name"/></TD>
<TD><xsl:valu e-of select="Period"/></TD>
<TD><xsl:valu e-of select="DueDate "/></TD>
<TD><xsl:valu e-of select="Type"/></TD>
</TR>
</xsl:for-each>
<</xsl:template>
</xsl:stylesheet>

Nov 11 '05 #1
4 3000
John Lehmann wrote:
I have an interesting problem. I am performing an XSL
transform using the System.Xml.Xsl. Transform class.
I have a database that contains the XSL style sheet
string. And it seems to work pretty well for simple
transforms. But as soon as I add Xsl variables or For each
loops to the XSL string in the db, it fails to transform
the XML. I can see that it will transform everything until
that point. ALso If I copy the XSL & XML I am trying to
transform from my watch window into a file.. It works
perfectly. Any Ideas?

That's bizarre. Most likely input XML is different that you think it is
so xsl:for-each just selects nothing. You didn't show us what XmlData is.
Also it's too expensive to build XmlDocument only to feed XslTransform -
you can rewrite transformation logic in more effective way:

XmlUrlResolver resolver = new XmlUrlResolver( );
XslTransform xslTran = new XslTransform();
XmlReader r = new XmlTextReader(n ew StringReader(Da taFormat));
xslTran.Load(r, resolver,null);

StringWriter sw = new StringWriter();
xslTran.Transfo rm(XmlData,null ,sw,resolver);
string output = sw.ToString();

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
John Lehmann wrote:
The Xml Looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<DataSource>
<tblReport>
<AgreementNumbe r>1234567</AgreementNumber >
<Name>Martha Stuart</Name>
<Period>July 2000</Period>
<DueDate>Augu st 15, 2000</DueDate>
<Type>Type II</Type>
</tblReport>
</DataSource>
Well, considering that XML xsl:for-each in your stylesheet really selects nothing:
<xsl:for-each select="tblRepo rt[code='XYZ']">


because in your XML tblReport has no child Code element.
--
Oleg Tkachenko
http://www.tkachenko.c om/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Just changing the way to open the transform WORK! Thanx
for you input!

John
-----Original Message-----
John Lehmann wrote:
I have an interesting problem. I am performing an XSL
transform using the System.Xml.Xsl. Transform class.
I have a database that contains the XSL style sheet
string. And it seems to work pretty well for simple
transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to
transform from my watch window into a file.. It works
perfectly. Any Ideas?That's bizarre. Most likely input XML is different that

you think it isso xsl:for-each just selects nothing. You didn't show us what XmlData is.Also it's too expensive to build XmlDocument only to feed XslTransform - you can rewrite transformation logic in more effective way:
XmlUrlResolv er resolver = new XmlUrlResolver( );
XslTransform xslTran = new XslTransform();
XmlReader r = new XmlTextReader(n ew StringReader (DataFormat));xslTran.Load(r ,resolver,null) ;

StringWriter sw = new StringWriter();
xslTran.Transf orm(XmlData,nul l,sw,resolver);
string output = sw.ToString();

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #4
Just changing the way to open the transform worked.
Unfortunately since I work on sensitive data at MS, I
could not copy everything as I see it exactly (I had to
cut out a lot of things). I may have missed my select..
But like I said.. it works now.
-----Original Message-----
John Lehmann wrote:
The Xml Looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<DataSource>
<tblReport>
<AgreementNumbe r>1234567</AgreementNumber >
<Name>Martha Stuart</Name>
<Period>July 2000</Period>
<DueDate>Augu st 15, 2000</DueDate>
<Type>Type II</Type>
</tblReport>
</DataSource>
Well, considering that XML xsl:for-each in your

stylesheet really selects nothing:
<xsl:for-each select="tblRepo rt[code='XYZ']">


because in your XML tblReport has no child Code element.
--
Oleg Tkachenko
http://www.tkachenko.c om/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #5

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

Similar topics

0
3025
by: Xiaolei Li | last post by:
first off, i'm a total newbie at this stuff so excuse any wrong usage of terminology or whatever else. i have a XSL to transform a Document such that all "text" nodes will have a "SPAN" inserted around it. the XSL is given below: <xsl:transform version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xhtml" omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/>
2
1024
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to...
1
2257
by: Brian McGuinness | last post by:
I have a question about using the STL transform algorithm in a function. What I want to do is define a group of array classes to represent APL-style arrays (arrays in which the number of dimensions and the length of any dimension can be changed at any time). What I currently plan is to have an abstract base class at the top, to allow polymorphism, e.g.: #include "basedefs.h" // Basic data types, e.g. typedef long Integer
5
3610
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an instruction document (not data based) - same as using an xml web control. The resulting html is on the client? but what about the server side of things? Trying to figure out how to change and save the xmlDocument. It I put a button OUTSIDE of the...
3
2478
by: Jason S | last post by:
Hello Group, I am just about tearing my hair out with this one and thought someone may have some insight. I have a transform that wasn't working so I grabbed the nearest debugger (xselerator) and saw that it works just fine. Now what I mean by not working is that it just silently fails to produce the expected output... no exceptions are being thrown. Xselerator uses msxml 3 so it's not really helping me see the problem in .net 1.1. ...
4
4823
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt transform via code? Any examples would be great.
6
1730
by: tcdevelopment | last post by:
I have a XSLT file that gives expected results when I transform using MSXML V4.0 in a simple vbs file. However when using XslTransform in dotnet, I do not get the same results. The part of the XSLT file that does not work correctly is: <Token TokenId="3129"> <xsl:for-each select="EDI/Segment/Element"> <Value Segment="PRF" Position="1"> <xsl:attribute name="SegmentIndex"> <xsl:value-of select="../@SegmentIndex"/></xsl:attribute>
4
8531
by: Dean Card | last post by:
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the image. The transform will take a rectangular 2D image and transform it to a 3D representation in 2D. Please see the link to see what I am trying to do: http://seanberry.com/transform.png I have PIL v1.15 installed which has a PERSPECTIVE...
12
10117
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
3
7347
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
0
10143
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
10076
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
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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
7486
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
6729
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
5375
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
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
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

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.