XSL Transform Problem using Xml.XSL.Transform

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.LoadXml(DataFormat); //DataFormat xsl string

XmlUrlResolver resolver = new XmlUrlResolver();
XslTransform xslTran = new XslTransform();
xslTran.Load(transform,resolver,null);
						
XmlReader reader = 
   xslTran.Transform(XmlData,null,resolver);
reader.MoveToContent();
string readerOutput = reader.ReadOuterXml();

//XSL
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DataSource">
<B>Report</B><BR/>
<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
<TR><TH>Agreement Number</TH>
<TH>Name</TH>
<TH>Period</TH>
<TH>Due Date</TH>
<TH>Type</TH>
</TR>
<xsl:for-each select="tblReport[Code='XYZ']">
<TR>
<TD><xsl:value-of select="AgreementNumber"/></TD>
<TD><xsl:value-of select="Name"/></TD>
<TD><xsl:value-of select="Period"/></TD>
<TD><xsl:value-of select="DueDate"/></TD>
<TD><xsl:value-of select="Type"/></TD>
</TR>
</xsl:for-each>
<</xsl:template>
</xsl:stylesheet>

0
v-jolehm (3)
9/22/2003 12:34:54 AM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
639 Views

Similar Articles

[PageSpeed] 57

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(new StringReader(DataFormat));
xslTran.Load(r,resolver,null);

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

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

0
oleg7603 (294)
9/22/2003 8:44:25 AM
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 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(new StringReader
(DataFormat));
>xslTran.Load(r,resolver,null);
>
>StringWriter sw = new StringWriter();
>xslTran.Transform(XmlData,null,sw,resolver);
>string output = sw.ToString();
>
>-- 
>Oleg Tkachenko
>http://www.tkachenko.com/blog
>Multiconn Technologies, Israel
>
>.
>
0
v-jolehm (3)
9/22/2003 6:03:02 PM
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>
>> <AgreementNumber>1234567</AgreementNumber>
>> <Name>Martha Stuart</Name>
>> <Period>July 2000</Period>
>> <DueDate>August 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="tblReport[Code='XYZ']">
>
>because in your XML tblReport has no child Code element.
>-- 
>Oleg Tkachenko
>http://www.tkachenko.com/blog
>Multiconn Technologies, Israel
>
>.
>
0
v-jolehm (3)
9/22/2003 6:11:49 PM
John Lehmann wrote:

> The Xml Looks something like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <DataSource>
> <tblReport>
> <AgreementNumber>1234567</AgreementNumber>
> <Name>Martha Stuart</Name>
> <Period>July 2000</Period>
> <DueDate>August 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="tblReport[Code='XYZ']">

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

0
oleg7603 (294)
9/22/2003 6:52:54 PM
Reply:

Similar Artilces:

Microsoft Money Opening Problem
I cannot open my money program. The error message I receive is "Msmoney has caused an error in MNYADV.DLL. Msmoney will now close." Doe anyone have any info on what may be wrong? I have not done anything different - just came home and could not open the program. Thank you. Hi Tawney Read my response to Greg on HELP! Restoring backup Good luck and let us know how you make out Bob "Tawney Milton" <smilton1@cox.net> wrote in message news:069501c34cbf$f3680190$a101280a@phx.gbl... > I cannot open my money program. The error message I > receive is "M...

Totals for labels when using stacking chart
I am attempting to create a "stacked column chart" with two data sets one set stacked on top the other. I would like to add the total valu of each "stacked" column to the table. When I select "Show Value", get the two subset values appearing on each stack. How can I get th total value, not the subset values, to show -- Message posted from http://www.ExcelForum.com You can add a third 'invisible' series with the total value as labels: Add a third series to the chart whose values are the sum of the colum elements Right click on the new series an set ...

Copy and Paste problems
I hope someone is able to help. The problem manifests itself in copy/paste activity. When I highlight a cell then click on the copy command, the spreadsheet whites out and stops working. Does anyone have a clue what is happening. Using Office 2007. Thanls -- John First, I have no idea. But lots of problems in excel (and windows) are caused by misbehaving printer drivers. Can you close excel, change printers and then retest. Please post back with your results. JohnH wrote: > > I hope someone is able to help. The problem manifests itself in copy/paste > activity. When I h...

Want to use a standard SQL Server for BCM
I already have a standard SQL Server 2000 installation on my computer and want to use that instead of a new instance of MSDE. Is this possible? "Niklas Fagrell" <fagrell@mininet.se> wrote in message news:<127601c3e013$8cd67050$a301280a@phx.gbl>... > I already have a standard SQL Server 2000 installation on > my computer and want to use that instead of a new > instance of MSDE. Is this possible? Just curious: what does this have to do with Outlook? ...

How can I use a worksheet to plot polar coordinates?
I am trying to use an Excel worksheet as the matrix for plotting polar coordinates. Is there a way that this can be done? Hi, Have a look at these web pages on the subject. http://www.oaltd.co.uk/Excel/SBXLPage.asp#Charting http://www.stfx.ca/people/bliengme/ExcelTips/Polar.htm http://www.andypope.info/charts/polarplot.htm Cheers Andy louradam wrote: > I am trying to use an Excel worksheet as the matrix for plotting polar > coordinates. Is there a way that this can be done? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

problem with GetChunk in windowsXP
Hi, I have a program using ADO with access database. It works quite smoothly in win2000, but in windows XP, there is serious problems, I use the following lines to get the buf from my db and it gives run time error. _variant_t varChunk; varChunk = MeasureDB->m_pRs->Fields->Item["Points"]->GetChunk(ChunkSize); COleVariant s1(varChunk); CString s2=s1.bstrVal; // this line gives exception error Thanks for any hints, Behzad ...

Steganography MFC program problem...
Hi all, I am trying to understand this piece of code. It is generating few errors.. Well i have commented the section where i get the exception about i is not defined. Whereas i is defined. But it keeps on giving me this error. If i define i of for loop ..still i get the same error. And also i dont understand what this statement" message_file.open("message.steg",ios::out|ios::binary);" is doing. I know its to open the file ..But there is no file by this name anywhere. So is it created itself to store the message that i type in or wt.... Any help would be highly appreciated...

Problem with serializing multiple collections with a base class #2
I have the following code. When I serialize the DriverCollection I would like to get both the Driver Collection and the DeletedItems collection. I end up with only the Driver collection. I have tried numerous attributes with no success. Any help would be appreciated... using System; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Collections; namespace SerialTest { #region BusinessObjectBase /// Summary description for BusinessObjectBase...

tiral problem/ cannot start due to enrypt problem
I DL'd the '04 trial, and installed fine. upon starting, it is giving me the message of not being able to start because it can't encrypt at the required level. I have 128 cypher strength installed, and reinstalled. any help here? thanks. ...

A general rule for using methods that create objects
Objects created by invoking methods do not seem to behave like normal objects in VBA. Consider that in other programming languages, once you set an equality, you can use either side of the expression interchangeably. For instance: A = B C = sqrt(A) will give you the same thing as A = B C = sqrt(B) But consider two examples where this interchangeability is not true in VBA. You can say: Set Ws = DBEngine.CreateWorkspace( Arguments ) (ie, A = B) and then you can say: Workspaces.Append Ws (similar to C = sqrt(A)) but you cannot do: Workspaces.Append DBEngine.Cr...

XSL feed-- Metadata -Deployement Mgr
hi when we publish from deployement manager the xsl files are getting changed!!! my question is from which table(or tables) of the MSCRM, the metadata for the XSL is feeded??? Thanks in advance OrganizationUIBase Mike greaterthantwo media Printable Quotes, Orders and Invoices, with line-item details, now available for MSCRM. http://www.greaterthantwo.com "Apple" <none@nospam.com> wrote in message news:ueXyX%233%23DHA.3536@TK2MSFTNGP10.phx.gbl... > hi > when we publish from deployement manager the xsl files are getting > changed!!! > > my question is fro...

SMTP FROM: command syntax problem
HI. I have recently noticed that some e-mails are not delivered to external mail servers on the internet. On closer inspection I found that by using the syntax: mail from:email@domain.com mail from: email@domain.com AND mail from:<email@domain.com> does not work and you receive a "501 bad address syntax" error. When using "mail from: <email@domain.com>" I receive a "250 ok" message. My question is this: 1. How does exchange send mail, what is the exact syntax? 2. Can a settings change on exchange cause the format of the mail message to change? 3...

Combo Box Problem 04-05-10
My Combo Box has no Control source and the Row Source type is Value List My Row Source is showing say 18;Dobbie,Chris Bound Column 1 My format is 3 column count 0cm:7cm;0cm but even if i try to show the last Column I am not getting "Chris" only when I click the arror do I see the name At the moment when I open my form I am getting just Dobbie and would like to get Dobbie, Chris -- Thanks in advance for any help with this......Bob MS Access 2007 accdb Windows XP Home Edition Ver 5.1 Service Pack 3 Bob It sounds like you are expecting the combobox to displa...

Outlook 2007 and Vista problems
Dear Anyone, I have recently installed Vista Business and Office 2007 on my development workstation. It's working quite well, except i have a critical problem with Outlook 2007. Whenever i try to access anything to do with the calendar, it hangs. The processor goes to 25% (one of the four cores maxed) and that's it. Game over. I'm connecting to an Exchange server, and everything works fine in XP with Office 2007 on a separate partition. Also, no problems with accessing the calendar using Outlook Web Access. Any ideas? TIA Notably, this seems to be a problem with the c...

Using Collapse/Expand with Protected worksheets
Hello -- someone has posted this great code that works well to allow this, but you need to list each individual worksheet. The problem is, i want to give my users the option of changing the worksheet tab title, and in fact this title is referenced repeatedly throughout the workbook. isn't there a way to apply this macro to "all worksheets" regardless of the name? the original code is below. Thanks very much!: Private Sub Workbook_Open() Dim mySheetNames As Variant Dim iCtr As Long 'change to match your workbook mySheetNames = Array("sheet1", "sheet2&qu...

Problems with a hyperlink to documents on my computer
In Excel I run into a problem after I've created a hyperlink to a document on my computer. I use Excel to create project maps, which are simply diagrams that help me organize things, and I like to set hyperlinks from the objects in the diagram to documents on my computer. However, sometimes after I've created the link I'll click on the object and get an error that says Excel cannot open the specified file. The objects I use in the diagram are either shapes from the object palette or a picture. I place these objects in the Excel document, select the object and hit ...

DLL Link problem.
Hello everybody. I have an EXE (myApp.Exe) linked statically to a DLL (myDLL.dll), I've changed the DLL name (nyNewDll.dll) and the 'Object/Library Modules' in EXE project, it compiles fines but the link is still with the old DLL, how can I link my Exe with the new DLL name? Thanks in advance, William GS ...

Investment Account Problems
I have Premium 2006 & Win98SE, and mainly use Money to track my investment accounts. But I'm having trouble. 1. I just did a few stock trades out of my retirement account, but when I did an update the trades did not show up in my Money register. I finally entered it in manually, but why did Money not do it automatically? BTW, I did a reconcile but that did not do it either. 2. After the sale, the proceeds did not show up in the Cash portion of the account. But if I look in the upper right corner of the Cash Transaction screen I have a line that says Bank Balance with the amount o...

xml #7
PFA kannadiga's wrote: > PFA WTF? ///Peter ...

Insert cell problem
On one worksheet, attempts to insert a cell are thwarted--only insert row or column is allowed--other options are grayed out. I've tried cells across the ENTIRE worksheet, and they all exhibit the same behavior. However, it DOES work normally if I copy and paste part of it into a new sheet. Is there some setting that can affect an entire sheet? There are no merged cells, or hidden rows or columns. (Yes, I am sure I am not selecting more than one cell!) Hi Dave, I expect you have Sheet protection turned on, but can't see how you would get some of the insert options. --- HTH, Davi...

Using existing fields in an IIf statement
I am trying to create a text field which displays an existing field is another field is null. The expression I have used is: =IIf([Home_Address]="",[Manager],Null). Unfortunately this doesn't work in that nothing is ever displayed, even if there is nothing in the [Home_Address] field. If I replace the [Home_Address] field with some text (like "No Data") then it works. Help would be appreciated. -- Keith W Try: =IIf([Home_Address] Is Null,[Manager], Null) Null is not the same thing as "" (a zero-length string.) For more info, see: Common erro...

What catagory to use for a CC payment? #2
I'm currently running Money 2005. The problem I'm having is with credit card payments. In my regular bank account anytime I make a CC payment I use "BILLS: Credit Card Payment" as the catagory. This works just fine... However, now that I can download my credit card statement with 2005 it's showing those payments as "income". So, when I run monthly reports it's not showing my true income for the month, it's showing my payroll checks plus all the credit card payments. Anyone has an idea of what category I can use in the CC account for those transac...

Recycle bin problems
One of my two boxes running XP Pro has developed a problem with the Recycle bin. The bin shows as empty. I delete something and get the normal dialog if you want to send it to the recycle bin, reply Yes and it vanishes. Recycle bin still shows empty icon and opening the bin shows no contents. Running disc cleanup shows that the recycle bin has 0 KB. It's almost like doing a shift del (bypassing the recycle bin and directly deleting) but I do get the delete confirmation dialog that specifies recycle bin. Any ideas on how to fix this? tia - Oppie Right Hand Click Re...

Forwarding Using Mail Enabled Users
Are there any differences forwarding mail to an external recipient using a mail enabled user vs a mailbox enabled user forwarding to a contact aside from the fact that the mail enabled user doesn't have a mailbox? In news:eRPSivG0FHA.3408@TK2MSFTNGP09.phx.gbl, Steve Fukumoto <steve.fukumoto@necsam.com> typed: > Are there any differences forwarding mail to an external recipient > using a mail enabled user vs a mailbox enabled user forwarding to a > contact aside from the fact that the mail enabled user doesn't have a > mailbox? A mail-enabled user has an external...

Problem with Page Breaks
Hello Forum, I'm running excel 2003, in XP. In the page break preview screen, I can no longer drag the "blue" page break lines around the worksheet like I used to be able to. For some reason, when I move my cursor over the blue page break lines, the cursor no longer turns into the shape of two-arrows like I think it used to, therefore I cannot "grab" the blue page break lines and drag them around to change the page sizing.............I have been able to do this since excel was invented, but some some reason now I can't. Maybe I need to make some minor adju...