473,241 Members | 1,439 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,241 software developers and data experts.

XslCompiledTransform load compile error

I am moving some code forward from .NET 1.1. I was able to load the XSL file
and perform the transform. The MSDN documentation looks like it should be
easy. But I get a compile error. Ideas ? How can I share my XSLT ( there
are 2 helper stylesheets, and I check that they are also available... the
loaded xsl makes reference to the helper xsl files. Where should I start
looking ?

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
xslt.Load(XSLDocPath); // ERROR HERE

// Transform the file.
errBefore = " xslt.Transform(xmlDocPath....);";
xslt.Transform(xmlDocPath, outputFileName);

--
Andrew
Jul 30 '06 #1
4 9530


andrewcw wrote:
I am moving some code forward from .NET 1.1. I was able to load the XSL file
and perform the transform. The MSDN documentation looks like it should be
easy. But I get a compile error. Ideas ? How can I share my XSLT ( there
are 2 helper stylesheets, and I check that they are also available... the
loaded xsl makes reference to the helper xsl files. Where should I start
looking ?

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
xslt.Load(XSLDocPath); // ERROR HERE
You need to show more context so that we know what types and values the
variables xslt and XSDDocPath have. Then tell us the exact and complete
error message and if it refers to the stylesheet show us the relevant
part of that.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 30 '06 #2
System.Xml.Xsl.XslCompiledTransform xslt = new XslCompiledTransform();

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
//xslt.Load(XSLDocPath)
xslt.Load(XSLDocPath);

XSLDocPath = type string and is a path like " C:\VersionTable.xsl"

The above code is within a try catch block and my error simply states
e.Message = "XSLT compile error."

What's odd is that the XSL worked fine in .NET 1.1

Here's the stylesheet and its 2 helper files (
include_VersionTableStyles.xsl and include_VersionTableHeader.xsl) - I dont
know of another way to let anyone see the XSL other than copy it here. Hope
this helps - Thanks

VersionTable.xsl:

<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY mdash "—">
<!ENTITY ndash "–"]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint">

<xsl:include href="include_VersionTableStyles.xsl" />
<xsl:include href="include_VersionTableHeader.xsl" />

<xsl:template match="/">
<xsl:processing-instruction name="mso-application">
<xsl:text>progid="Word.Document"</xsl:text>
</xsl:processing-instruction>

<w:wordDocument xml:space="preserve"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint">

<xsl:call-template name="VersionTableStyles" />
<w:body>
<wx:sect>
<w:tbl>
<xsl:call-template name="VersionTableHeader" />

<xsl:apply-templates/>

</w:tbl>
<w:p/>
<w:sectPr>
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800"
w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:line-pitch="360"/>
</w:sectPr>
</wx:sect>
</w:body>
</w:wordDocument>

</xsl:template>

<!-- The category (chapter) content -->
<xsl:template match="files" >

<xsl:apply-templates>
<xsl:sort select="name" />
</xsl:apply-templates>

</xsl:template>

<xsl:template match="file" >

<w:tr>
<w:trPr>
<w:cantSplit/>
</w:trPr>
<xsl:apply-templates />

</w:tr>

</xsl:template>
<!-- The file name content -->
<xsl:template match="name" >
<w:tc>
<w:tcPr>
<w:tcW w:w="2988" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:pStyle w:val="TableText"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="." /></w:t>
</w:r>
</w:p>
</w:tc>
</xsl:template>

<!-- The file type content -->
<xsl:template match="type" >
<w:tc>
<w:tcPr>
<w:tcW w:w="1080" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:pStyle w:val="TableText"/>
<w:tabs>
<w:tab w:val="left" w:pos="4284"/>
</w:tabs>
<w:ind w:right="72"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="." /></w:t>
</w:r>
</w:p>
</w:tc>
</xsl:template>

<!-- The file version number content -->
<xsl:template match="version" >
<w:tc>
<w:tcPr>
<w:tcW w:w="1440" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:pStyle w:val="TableText"/>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="." /></w:t>
</w:r>
</w:p>
</w:tc>
</xsl:template>

<!-- The file size value content -->
<xsl:template match="size" >
<w:tc>
<w:tcPr>
<w:tcW w:w="1350" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:pStyle w:val="TableText"/>
<w:ind w:right="72"/>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="." /></w:t>
</w:r>
</w:p>
</w:tc>
</xsl:template>

<!-- The file date/time stamp content -->
<xsl:template match="timestamp" >
<w:tc>
<w:tcPr>
<w:tcW w:w="2442" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:pStyle w:val="TableText"/>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="." /></w:t>
</w:r>
</w:p>
</w:tc>
</xsl:template>

</xsl:stylesheet>

///// next file :include_VersionTableStyles.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint">
<xsl:template name="VersionTableStyles">
<w:styles>
<w:versionOfBuiltInStylenames w:val="4"/>
<w:latentStyles w:defLockedState="off" w:latentStyleCount="156"/>
<w:style w:type="paragraph" w:default="on" w:styleId="Normal">
<w:name w:val="Normal"/>
<w:rsid w:val="00C44DED"/>
<w:pPr>
<w:spacing w:after="240"/>
<w:ind w:left="360"/>
</w:pPr>
<w:rPr>
<wx:font wx:val="Times New Roman"/>
<w:sz w:val="24"/>
<w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:default="on" w:styleId="DefaultParagraphFont">
<w:name w:val="Default Paragraph Font"/>
<w:semiHidden/>
</w:style>
<w:style w:type="table" w:default="on" w:styleId="TableNormal">
<w:name w:val="Normal Table"/>
<wx:uiName wx:val="Table Normal"/>
<w:semiHidden/>
<w:rPr>
<wx:font wx:val="Times New Roman"/>
</w:rPr>
<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>
<w:style w:type="list" w:default="on" w:styleId="NoList">
<w:name w:val="No List"/>
<w:semiHidden/>
</w:style>
<w:style w:type="paragraph" w:styleId="TableText">
<w:name w:val="Table Text"/>
<w:basedOn w:val="Normal"/>
<w:link w:val="TableTextChar"/>
<w:rsid w:val="00C44DED"/>
<w:pPr>
<w:pStyle w:val="TableText"/>
<w:spacing w:before="40" w:after="40"/>
<w:ind w:left="0"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Arial" w:h-ansi="Arial"/>
<wx:font wx:val="Arial"/>
<w:sz w:val="20"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:styleId="TableTextChar">
<w:name w:val="Table Text Char"/>
<w:basedOn w:val="DefaultParagraphFont"/>
<w:link w:val="TableText"/>
<w:rsid w:val="00C44DED"/>
<w:rPr>
<w:rFonts w:ascii="Arial" w:h-ansi="Arial"/>
<w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/>
</w:rPr>
</w:style>
<w:style w:type="table" w:styleId="TableGrid">
<w:name w:val="Table Grid"/>
<w:basedOn w:val="TableNormal"/>
<w:rsid w:val="00C44DED"/>
<w:pPr>
<w:spacing w:after="240"/>
<w:ind w:left="360"/>
</w:pPr>
<w:rPr>
<wx:font wx:val="Times New Roman"/>
</w:rPr>
<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblBorders>
<w:top w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto"/>
<w:left w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0"
w:color="auto"/>
<w:bottom w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0"
w:color="auto"/>
<w:right w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0"
w:color="auto"/>
<w:insideH w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0"
w:color="auto"/>
<w:insideV w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0"
w:color="auto"/>
</w:tblBorders>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>
</w:styles>
</xsl:template>
</xsl:stylesheet>

///// the other file :include_VersionTableHeader.xsl

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<xsl:template name="VersionTableHeader">
<w:tblPr>
<w:tblStyle w:val="TableGrid"/>
<w:tblW w:w="9300" w:type="dxa"/>
<w:tblLayout w:type="Fixed"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="2988"/>
<w:gridCol w:w="1080"/>
<w:gridCol w:w="1440"/>
<w:gridCol w:w="1350"/>
<w:gridCol w:w="2442"/>
</w:tblGrid>
<w:tr>
<w:trPr>
<w:cantSplit/>
<w:tblHeader/>
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="2988" w:type="dxa"/>
<w:shd w:val="clear" w:color="auto" w:fill="CCCCCC"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:b-cs/>
<w:sz-cs w:val="24"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
<w:t>Name</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1080" w:type="dxa"/>
<w:shd w:val="clear" w:color="auto" w:fill="CCCCCC"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:tabs>
<w:tab w:val="left" w:pos="4284"/>
</w:tabs>
<w:ind w:left="72" w:right="72"/>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
<w:t>Type</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1440" w:type="dxa"/>
<w:shd w:val="clear" w:color="auto" w:fill="CCCCCC"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:ind w:left="72"/>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
<w:t>Version</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1350" w:type="dxa"/>
<w:shd w:val="clear" w:color="auto" w:fill="CCCCCC"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:ind w:left="72"/>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
<w:t>Size</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="2442" w:type="dxa"/>
<w:shd w:val="clear" w:color="auto" w:fill="CCCCCC"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:ind w:left="72"/>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
</w:rPr>
<w:t>TimeStamp</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</xsl:template>
</xsl:stylesheet>

--
Andrew
"Martin Honnen" wrote:
>

andrewcw wrote:
I am moving some code forward from .NET 1.1. I was able to load the XSL file
and perform the transform. The MSDN documentation looks like it should be
easy. But I get a compile error. Ideas ? How can I share my XSLT ( there
are 2 helper stylesheets, and I check that they are also available... the
loaded xsl makes reference to the helper xsl files. Where should I start
looking ?

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
xslt.Load(XSLDocPath); // ERROR HERE

You need to show more context so that we know what types and values the
variables xslt and XSDDocPath have. Then tell us the exact and complete
error message and if it refers to the stylesheet show us the relevant
part of that.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 30 '06 #3


andrewcw wrote:
System.Xml.Xsl.XslCompiledTransform xslt = new XslCompiledTransform();

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
//xslt.Load(XSLDocPath)
xslt.Load(XSLDocPath);

XSLDocPath = type string and is a path like " C:\VersionTable.xsl"

The above code is within a try catch block and my error simply states
e.Message = "XSLT compile error."
Well then don't be so lazy next time and examine the thrown exception
chain yourself with the debugger or by changing that try/catch code.
What's odd is that the XSL worked fine in .NET 1.1
XML parsing has changed, lots of stuff that works with .NET 1.x for
security reason requires explict settings in .NET 2.0 to work.

VersionTable.xsl:

<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY mdash "—">
<!ENTITY ndash "–"]>
One problem is the DOCTYPE declaration, the .NET 2.0 XML parser by
default gives an error on that, you have to explictly enable DTD
processing so you need code alike

XslCompiledTransform xsltProcessor = new XslCompiledTransform();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.None;
xsltProcessor.Load(XmlReader.Create(@"VersionTable .xsl", settings));

to load that stylesheet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 30 '06 #4
Thank You very much ! It works !!!
--
Andrew
"Martin Honnen" wrote:
>

andrewcw wrote:
System.Xml.Xsl.XslCompiledTransform xslt = new XslCompiledTransform();

// Load the stylesheet.
errBefore = "xslt.Load(XSLDocPath....);";
//xslt.Load(XSLDocPath)
xslt.Load(XSLDocPath);

XSLDocPath = type string and is a path like " C:\VersionTable.xsl"

The above code is within a try catch block and my error simply states
e.Message = "XSLT compile error."

Well then don't be so lazy next time and examine the thrown exception
chain yourself with the debugger or by changing that try/catch code.
What's odd is that the XSL worked fine in .NET 1.1

XML parsing has changed, lots of stuff that works with .NET 1.x for
security reason requires explict settings in .NET 2.0 to work.

VersionTable.xsl:

<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY mdash "—">
<!ENTITY ndash "–"]>

One problem is the DOCTYPE declaration, the .NET 2.0 XML parser by
default gives an error on that, you have to explictly enable DTD
processing so you need code alike

XslCompiledTransform xsltProcessor = new XslCompiledTransform();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.None;
xsltProcessor.Load(XmlReader.Create(@"VersionTable .xsl", settings));

to load that stylesheet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 30 '06 #5

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

Similar topics

0
by: Matt | last post by:
With VS2005 I see that the XslTransform class has been deprecated and XslCompiledTransform has replaced it. I am having issues with trying to get the new class to work how it did with the old. I...
1
by: Steve | last post by:
Using VB.NET 2.0 I have a simple routine that attempts transforms an XmlDocument with an XSLT stylesheet into HTML. Under the old 1.1 framework with XslTransform, everything worked fine. Now...
6
by: W. Jordan | last post by:
Hello there, Are there anybody who is using the XslCompiledTransform that comes with .net framework, which was said to be a replacement of the XslTransform class? I found that the class has...
1
by: S. David Kyle | last post by:
I am having a weird issue when I generate an input Html tag from a Xsl transformation. When the trasform is executed on the xsl below, the <inputtag has the closing slash removed in the first...
12
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)...
2
by: tony | last post by:
XslCompiledTransform xslt = new XslCompiledTransform(); ASCIIEncoding encodeToByteArray = new ASCIIEncoding(); MemoryStream inputStream = new MemoryStream(); MemoryStream outputStream = new...
1
by: Hans Kesting | last post by:
Hi, In our ASP.Net webapplications, we use xslt a lot. For 1.1 developing was "easy": start up the website and go to the page where the xslt was used. Change the xslt (save it) and refresh the...
1
by: Mark | last post by:
I'm getting the error "The URI scheme is too long." in the code below. What is URI in this context? The XSL or the XML being transformed? Thanks! -Mark StringBuilder sb = new...
1
by: =?Utf-8?B?Vmlub2Q=?= | last post by:
Hi, I am having a problem doing the transform. Actually i am migrating the code from XslTranform class into XslCompiledTransform class. Here is the code that i am using in .net 1.1 private...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.