Xslt compile error at 2, 2

xslt compile error at 2, 2

SaxonApiException: Stylesheet compilation failed: 2 errors reported at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:546) at. Judging from the error message, the XSL processor thinks there is an unexpected processing instruction in the document, somewhere around line 2. For use with SaxonJS 2, SEFs must be produced with Saxon-EE 10.0 or later, Bug #4725: Saxon-JS 2 fails to compile XSLT stylesheet giving error "Required.

Opinion you: Xslt compile error at 2, 2

Error resolving stream host [waiting 30s]
Bad request error 400 blackberry
Xslt compile error at 2, 2
CGPAV ERROR CHECKING FILE /VAR/COMMUNIGATE/QUEUE
Xslt compile error at 2, 2
Use the parse() function in the util namespace element of the current <message> element, and

Error handling with libxml error handling functions

libxml offers a number of functions for handling errors, which can be employed to capture and deal with errors in XSLT processing.

Example #1 fruits.xml

A valid XML file.

<fruits> <fruit>Apple</fruit> <fruit>Banana</fruit> <fruit>Cherry</fruit> </fruits>

Example #2 fruits.xsl

Contains an invalid select expression.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8" indent="no"/> <xsl:template match="fruits"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fruit"> <li><xsl:value-of select="THIS IS A DELIBERATE ERROR!"/></li> </xsl:template> </xsl:stylesheet>

Example #3 Collating and printing errors

The example below captures and displays libxml errors raised when calling XSLTProcessor::importStyleSheet() with a stylesheet containing an error, 2.

The above example will output something similar to:

Libxml error: Invalid expression Libxml error: compilation error: file fruits.xsl line 9 element value-of Libxml error: xsl:value-of : could not compile select expression 'THIS IS A DELIBERATE Xslt compile error at 2

add a note

User Contributed Notes

There are no user contributed notes for this page.

To Top
@*"> <!-- Copy the current node --> <xsl:copy> <!-- Including any attributes it has and any child nodes --> <xsl:apply-templates select="@*

XslCompiledTransform load compile error

andrewcw

2 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., 2. the
loaded xsl makes reference to the helper xsl files, 2. 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

Martin Honnen



andrewcw wrote:

I am moving some code forward from .NET 1.1. I was able to load the XSL file
and perform the transform, 2. The MSDN documentation looks like it should be
easy, xslt compile error at 2. But I get a compile error. Ideas ? How can I share my XSLT ( there
are 2 helper stylesheets, 2, and I check that they are also available. the
loaded xsl makes reference to the helper xsl files, 2. 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 keygen chernobyl terrorist attack to the stylesheet show us the relevant
part of that.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jul 30 '06

andrewcw

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 [
xslt compile error at 2 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 xslt compile error at 2 /></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">
xslt compile error at 2 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" xslt compile error at 2 <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 kernel data impage error 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 xslt compile error at 2 moving some code forward from .NET 1.1, xslt compile error at 2. I was able to load the XSL file
and perform the transform. The MSDN documentation looks like it should be
easy, 2. But I get a compile error. Ideas ? How can I share my XSLT ( there
are 2 helper stylesheets, xslt compile error at 2, and I check that they are also available., 2. 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 xslt compile error at 2

Martin Honnen



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 2 VersionTable.xsl:

<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY mdash "—">
<!ENTITY ndash "–"]> One problem is the DOCTYPE declaration, xslt compile error at 2, the .NET 2.0 XML parser by
default gives an error 2 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 2

andrewcw

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;
2 xsltProcessor.Load(XmlReader.Create(@"VersionTable .xsl", settings));

to load that stylesheet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jul 30 '06

This discussion thread is closed

Start new discussion

Replies have been disabled for this discussion.

xslt compile error at 2, 2

Xslt compile error at 2, 2 - here not

XSL Transformations (XSLT) Version 3.0

2.3 Initiating a Transformation

This document does not specify any application programming interfaces or other interfaces for initiating a transformation. This section, however, describes the information that is supplied when a transformation is initiated. Except where otherwise indicated, the information is required.

The execution of a stylesheet necessarily involves two activities: static analysis and dynamic evaluation. Static analysis consists of those tasks that can be performed by inspection of the stylesheet alone, including the binding of static variables, the evaluation of expressions (see 3.13.1 Conditional Element Inclusion), and shadow attributes (see 3.13.2 Shadow Attributes) and detection of static errors. Dynamic evaluation consists of tasks which in general cannot be carried out until a source document is available.

Dynamic evaluation is further divided into two activities: priming the stylesheet, and invoking a selected component.

  • Priming the stylesheet provides the dynamic context for evaluation, and supplies all the information needed to establish the values of global variables.

  • Invoking a component (such as a template or function) causes evaluation of that template or function to produce a result, which is an arbitrary XDM value.

    [Definition: The result of invoking the selected component, after any required conversion to the declared result type of the component, is referred to as the raw result.]

    The raw result of the invocation is the immediate result of evaluating the sequence constructor contained in the target template or function, modified by applying the function conversion rules to convert the immediate result to the type declared in the attribute of the or declaration, if present.

    This raw result may optionally be post-processed to construct a result tree, to serialize the result, or both, as described in 2.3.6 Post-processing the Raw Result.

Implementations may allow static analysis and dynamic evaluation to be initiated independently, so that the cost of static analysis can be amortized over multiple transformations using the same stylesheet. Implementations may also allow priming of a stylesheet and invocation of components to be initiated independently, in which case a single act of priming the stylesheet may be followed by a series of independent component invocations. Although this specification does not require such a separation, this section distinguishes information that is needed before static analysis can proceed, information that is needed to prime the stylesheet, and information that is needed when invoking components.

The language is designed to allow the static analysis of each package to be performed independently of other packages, with only basic knowledge of the properties of components made available by used packages. Beyond this, the specification leaves it to implementations to decide how to organize this process. When packages are not used explicitly, the entire stylesheet is treated as a single package.

2.3.1 Information needed for Static Analysis

The following information is needed prior to static analysis of a package:

Conceptually, the output of the static analysis of a package is an object which might be referred to (without constraining the implementation) as a compiled package. Prior to dynamic evaluation, all the compiled packages needed for execution must be checked for consistency, and component references must be resolved. This process may be referred to, again without constraining the implementation, as linking.

2.3.2 Priming a Stylesheet

The information needed when priming a stylesheet is as follows:

  • A set (possibly empty) of values for non-staticstylesheet parameters (see 9.5 Global Variables and Parameters). These values are available for use within expressions in the stylesheet. As a minimum, values must be supplied for any parameters declared with the attribute .

    A supplied value is converted if necessary to the declared type of the stylesheet parameter using the function conversion rules.

    Note:

    Non-static stylesheet parameters are implicitly, which ensures that all the parameters in the stylesheet for which values can be supplied externally have distinct names. Static parameters, by contrast, are local to a package.

  • [Definition: An item that acts as the global context item for the transformation. This item acts as the context item when evaluating the expression or sequence constructor of a global variable declarationwithin the top-level package, as described in 5.3.3.1 Maintaining Position: the Focus. The global context item may also be available in a named template when the stylesheet is invoked as described in 2.3.4 Call-Template Invocation].

    Note:

    In previous releases of this specification, a single node was typically supplied to represent the source document for the transformation. This node was used as the target node for the implicit call on used to start the transformation process (now called the initial match selection), and the root node of the containing tree was used as the context item for evaluation of global variables (now called the global context item). This relationship between the initial match selection and the global context item is likely to be found for compatibility reasons in a transformation API designed to work with earlier versions of this specification, but it is no longer a necessary relationship; the two values can in principle be completely independent of each other.

    Stylesheet authors wanting to write code that can be invoked using legacy APIs should not rely on the caller being able to supply different values for the initial match selection and the global context item.

    The value given to the global context item (and the values given to stylesheet parameters) cannot be nodes in a streamed document. This rule ensures that all global variables can freely navigate within the relevant tree, with no constraints imposed by the streamability rules.

    The global context item is potentially used when initializing global variables and parameters. If the initialization of any global variables or parameter depends on the context item, a dynamic error can occur if the context item is absent. It is implementation-defined whether this error occurs during priming of the stylesheet or subsequently when the variable is referenced; and it is implementation-defined whether the error occurs at all if the variable or parameter is never referenced. The error can be suppressed by use of and within the sequence constructor used to initialize the variable or parameter. It cannot be suppressed by use of around a reference to the global variable.

    In a library package, the context item, context position, and context size used for evaluation of global variables will be absent, and the evaluation of any expression that references these values will result in a dynamic error. This will also be the case in the top-level package if no global context item is supplied.

    Note:

    If a context item is available within a global variable declaration, then the context position and context size will always be 1 (one).

    Note:

    For maximum reusability of code, it is best to avoid use of the context item when initializing global variables and parameters. Instead, all external information should be supplied using named stylesheet parameters. Especially when these use namespaces to avoid conflicts, there is then no risk of confusion between the information supplied externally to different packages.

    When a stylesheet parameter is defined in a library package, it is possible for a using package to supply a value for the parameter by overriding the parameter declaration within an element. If the using package is the top-level package then the overriding declaration can refer to the global context item.

  • A mechanism for obtaining a document node and a media type, given an absolute URI. The total set of available documents (modeled as a mapping from URIs to document nodes) forms part of the context for evaluating XPath expressions, specifically the FO30 function. The XSLT function additionally requires the media type of the resource representation, for use in interpreting any fragment identifier present within a URI Reference.

    Note:

    The set of documents that are available to the stylesheet is implementation-dependent, as is the processing that is carried out to construct a tree representing the resource retrieved using a given URI. Some possible ways of constructing a document (specifically, rules for constructing a document from an Infoset or from a PSVI) are described in [XDM 3.0].

Once a stylesheet is primed, the values of global variables remain stable through all component invocations. In addition, priming a stylesheet creates an execution scopeFO30 during which the dynamic context and all calls on deterministicFO30 functions remain stable; for example two calls on the FO30 function within an execution scope are defined to return the same result.

Parameters passed to the transformation by the client application when a stylesheet is primed are matched against stylesheet parameters (see 9.5 Global Variables and Parameters), not against the template parameters of any template executed during the course of the transformation.

[ERR XTDE0050] It is a dynamic error if a stylesheet declares a visible stylesheet parameterthat is explicitly or implicitly mandatory, and no value for this parameter is supplied when the stylesheet is primed. A stylesheet parameter is visible if it is not masked by another global variable or parameter with the same name and higher import precedence. If the parameter is a static parameter then the value must be supplied prior to the static analysis phase.

2.3.3 Apply-Templates Invocation

[Definition: A stylesheet may be evaluated by supplying a value to be processed, together with an initial mode. The value (which can be any sequence of items) is referred to as the initial match selection. The processing then corresponds to the effect of the instruction.]

The initial match selection will often be a single document node, traditionally called the source document of the transformation; but in general, it can be any sequence. If the initial match selection is an empty sequence, the result of the transformation will be empty, since no template rules are evaluated.

Processing proceeds by finding the template rules that match the items in the initial match selection, and evaluating these template rules with a focus based on the initial match selection. The template rules are evaluated in final output state.

The following information is needed when dynamic evaluation is to start with a template rule:

  • The initial match selection. An API that chooses to maintain compatibility with previous versions of this specification should allow a method of invocation in which a singleton node is provided, which is then used in two ways: the node itself acts as the initial match selection, and the root node of the containing tree acts as the global context item.

  • Optionally, an initial mode.

    [Definition: The initial mode is the mode used to select template rules for processing items in the initial match selection when apply-templates invocation is used to initiate a transformation.]

    In searching for the template rule that best matches the items in the initial match selection, the processor considers only those rules that apply to the initial mode.

    If no initial mode is supplied explicitly, then the initial mode is that named in the attribute of the (explicit or implicit) element of the top-level package or in the absence of such an attribute, the unnamed mode.

    [ERR XTDE0044] It is a dynamic error if the invocation of the stylesheet specifies an initial mode when no initial match selection is supplied (either explicitly, or defaulted to the global context item).

    A (named or unnamed) mode is eligible as an initial mode if one of the following conditions applies, where is the top-level package of the stylesheet:

    1. is explicitly declared in an declaration within , and has or visibility (either by virtue of its attribute, or by virtue of an declaration).

    2. is the unnamed mode.

    3. is named in the attribute of the (explicit or implicit) element of .

    4. is declared in a package used by , and is given or visibility in by means of an declaration.

    5. The effective value of the attribute of the explicit or implicit element of is , and appears as a mode-name in the attribute of a template rule declared within .

    [ERR XTDE0045] It is a dynamic error if the invocation of the stylesheet specifies an initial mode and the specified mode is not eligible as an initial mode (as defined above).

  • Parameters, which will be passed to the template rules used to process items in the input sequence. The parameters consist of two sets of (QName, value) pairs, one set for tunnel parameters and one for non-tunnel parameters, in which the QName identifies the name of a parameter and the value provides the value of the parameter. Either or both sets of parameters may be empty. The effect is the same as when a template is invoked using with an child specifying or as appropriate. If a parameter is supplied that is not declared or used, the value is simply ignored. These parameters are not used to set stylesheet parameters.

    A supplied value is converted if necessary to the declared type of the template parameter using the function conversion rules.

  • Details of how the result of the initial template is to be returned. For details, see 2.3.6 Post-processing the Raw Result

The raw result of the invocation is the result of processing the supplied input sequence as if by a call on in the specified mode: specifically, each item in the input sequence is processed by selecting and evaluating the best matching template rule, and converting the result (if necessary) to the type declared in the attribute of that template using the function conversion rules; and the results of processing each item are then concatenated into a single sequence, respecting the order of items in the input sequence.

Note:

If the initial mode is declared-streamable, then a streaming processor should allow some or all of the items in the initial match selection to be nodes supplied in streamable form, and any nodes that are supplied in this form must then be processed using streaming.

Since the global context item cannot be a streamed node, in cases where the transformation is to proceed by applying streamable templates to a streamed input document, the global context item must either be absent, or must be something that differs from the initial match selection.

Note:

The design of the API for invoking a transformation should provide some means for users to designate the unnamed mode as the initial mode in cases where it is not the default mode.

It is a dynamic error[see ERR XTDE0700] if the template rule selected for processing any item in the initial match selection defines a template parameter that specifies and no value is supplied for that parameter.

2.3.4 Call-Template Invocation

[Definition: A stylesheet may be evaluated by selecting a named template to be evaluated; this is referred to as the initial named template.] The effect is analogous to the effect of executing an instruction. The following information is needed in this case:

  • Optionally, the name of the initial named template which is to be executed as the entry point to the transformation. If no template name is supplied, the default template name is . The selected template must exist within the stylesheet.

  • Optionally, a context item for evaluation of this named template, defaulting to the global context item if it exists. This is constrained by any element appearing within the selected element. The initial named template is evaluated with a singleton focus based on this context item if it exists, or with an absent focus otherwise.

  • Parameters, which will be passed to the selected template rule. The parameters consist of two sets of (QName, value) pairs, one set for tunnel parameters and one for non-tunnel parameters, in which the QName identifies the name of a parameter and the value provides the value of the parameter. Either or both sets of parameters may be empty. The effect is the same as when a template is invoked using with an child specifying or as appropriate. If a parameter is supplied that is not declared or used, the value is simply ignored. These parameters are not used to set stylesheet parameters.

    A supplied value is converted if necessary to the declared type of the template parameter using the function conversion rules.

  • Details of how the result of the initial named template is to be returned. For details, see 2.3.6 Post-processing the Raw Result

The raw result of the invocation is the result of evaluating the initial named template, after conversion of the result to the type declared in the attribute of that template using the function conversion rules, if such conversion is necessary.

The initial named template is evaluated in final output state.

[ERR XTDE0040] It is a dynamic error if the invocation of the stylesheet specifies a template name that does not match the expanded QName of a named template defined in the stylesheet, whose visibility is or .

It is a dynamic error[see ERR XTDE0700] if the initial named template, or any of the template rules invoked to process items in the initial match selection, defines a template parameter that specifies and no value is supplied for that parameter.

2.3.5 Function Call Invocation

[Definition: A stylesheet may be evaluated by calling a named stylesheet function, referred to as the initial function.] The following additional information is needed in this case:

  • The name and arity of a stylesheet function which is to be executed as the entry point to the transformation.

    Note:

    In the design of a concrete API, the arity may be inferred from the length of the parameter list.

  • A list of values to act as parameters to the initial function. The number of values in the list must be the same as the arity of the function.

    A supplied value is converted if necessary to the declared type of the function parameter using the function conversion rules.

  • Details of how the result of the initial function is to be returned. For details, see 2.3.6 Post-processing the Raw Result

The raw result of the invocation is the result of evaluating the initial function, after conversion of the result to the type declared in the attribute of that function using the function conversion rules, if such conversion is necessary.

If the initial function is declared-streamable, a streaming processor should allow the value of the first argument to be supplied in streamable form, and if it is supplied in this form, then it must

the "Util" class. The Util.java class is not in any

Error handling with libxml error handling functions

libxml offers a number of functions for handling errors, which can be employed to capture and deal with errors in XSLT processing.

Example #1 fruits.xml

A valid XML file.

<fruits> <fruit>Apple</fruit> <fruit>Banana</fruit> <fruit>Cherry</fruit> </fruits>

Example #2 fruits.xsl

Contains an invalid select expression.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8" indent="no"/> <xsl:template match="fruits"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fruit"> <li><xsl:value-of select="THIS IS A DELIBERATE ERROR!"/></li> </xsl:template> </xsl:stylesheet>

Example #3 Collating and printing errors

The example below captures and displays libxml errors raised when calling XSLTProcessor::importStyleSheet() with a stylesheet containing an error.

The above example will output something similar to:

Libxml error: Invalid expression Libxml error: compilation error: file fruits.xsl line 9 element value-of Libxml error: xsl:value-of : could not compile select expression 'THIS IS A DELIBERATE ERROR!'

add a note

User Contributed Notes

There are no user contributed notes for this page.

To Top
@*"> <!-- Copy the current node --> <xsl:copy> <!-- Including any attributes it has and any child nodes --> <xsl:apply-templates select="@* return the root node of the document +--> <xsl:variable name="body" select="util:parse(body)"/> <xsl:text>Items Ordered</xsl:text><xsl:text>&#xa;</xsl:text> <xsl:for-each select="$body/order/item"> <xsl:value-of select="@id"/><xsl:text>&#xa;</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>

I have a question about XSL. My XML document is similar to the following:

<ROW num="1"> <TITLE>New Java Classes</TITLE> <URL>/products/intermedia/</URL> <DESCRIPTION>&#60;a href=\"/products/intermedia/\">Java classes for Servlets and JSPs&#60;/a>are available. </DESCRIPTION> </ROW>

When I use XSL to display the XML document in HTML, the description is not displaying as a link eventhough I am specifying it as in XML.

My XSL file is:

<xsl:template> <P><FONT face="arial" size="4"><B> <xsl:value-of disable-output-escaping="yes" select="TITLE"/> </B> </FONT><BR></BR><FONT size="2"> <xsl:value-of disable-output-escaping="yes" select="DESCRIPTION"/></FONT> </P> </xsl:template>

You can simply build the tag in your XSL transform. Do something like this:

<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:for-each select="rowset"> <table border="1"> <th>Category</th> <th>ID</th> <th>Title</th> <th>Thumbnail</th> <xsl:for-each select="row"> <tr> <td><xsl:value-of select="category"/> </td> <td><xsl:value-of select="id"/> </td> <td><a href="Present.jsp?page=PRES_VIEW_SINGLE&amp;id={id}"><xsl:value-of select="title"/> </a></td> <td><img src="/servlets/thumb?presentation={id}&amp;slide=0" /></td> </tr> </xsl:for-each> </table> </xsl:for-each> </xsl:template> </xsl:stylesheet>

I am using included in XDK for Java v2 to perform an XSL transformation on an XML document. I need a WML output. My stylesheet contains the following code:

<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="no" encoding="ISO-8859-1"/> <xsl:output doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml" doctype-public="-//WAPFORUM//DTD WML 1.1//EN"/>

...

When I check the transformation using a servlet, I get the following error in my WAP emulator:

"Received HTTP status: 502 - WML Encoding Error, 1:com.sun.xml.parser/P-076 Malformed UTF-8 char

Is an XML encoding declaration missing? In fact, the WML generated is not including any XML header information. The output starts like this:

<wml> <card id="gastronomia" title="Mis direcciones de gastronomia"><p>Mis direcciones de gastronomia</p> ...

How do I get the transformer to output the XML header:

Use . Also ensure your stylesheet has:

<xsl:output method="xml"/>

just inside the , and outside of any

Also ensure that you're using the following API:

My BC4J source XML file has the following line that refers to the DTD:

<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">

When transforming the file, this line results in an error, saying it cannot find . The DTD file is in my classpath.

There are two solutions to this.

  • Extract from and put it in the same directory as your VO files. This is complicated if you have VO files at several different directory levels.
  • Use the trick that BC4J itself uses when parsing its own XML metadata files when parsing in your program: DOMParser d = new DOMParser(); // read DTD as a resource from the classpath InputStream is = ...getResourceAsStream("/jbo_03_01.dtd"); d.parseDTD( is ); DTD dtd = d.getDoctype();

d.setDoctype( dtd ); // set and cache the DTD to use.

// Now, subsequences calls to d.parse() will

// use the cached version of jbo_03_01.dtd

Then transform the result using XSLStylesheet and .

My second question relates to namespaces. I have the following piece of code in my stylesheet:

<xsl:attribute name="data:text"> <xsl:value-of select="@Name"/>@ipet:dataBindingObject </xsl:attribute>

At the top of my stylesheet, I have defined the namespace:

xmlns:data="http://xxx.us.yyy.com/cabo/marlin"

In the resulting XML file (the UIX file), the namespace definition is repeated for each element:

<messageTextInput id="Status" name="Status" prompt="Status" required="yes"xmlns:data="http://xxx.us.yyy.com/cabo/marlin" data:text="[email protected]:dataBindingObject" rows="1" maximumLength="3" columns="3"/>

Try defining the data namespace prefix on the document element in your XSLT root template. If it is defined at a higher level in the result tree we may notice that and not output it on each lower level element.

JDeveloper9i has virtual Virtual Objects (VOs) that expose the metadata of aVO kind of like the database views. This means that you could use the normal method against one of these virtual metadata views to perform operations like I think you are trying to do to render a data-driven output based on the structure of a given VO.

Is there a way to pass a parameter from a Java program to an XSLT stylesheet using Oracle XSL processor? The XSLT standard states that "...XSLT does not define the mechanism by which parameters arepassed to the stylesheet." (see ). This is possible, but is a vendor-dependant implementation. However, none of the XSL constructors in the seems to allow for this.

We need to pass in an integer to a stylesheet and use the function to extract a document fragmentfrom an XML doc. For example:

<xsl:templatematch="ROW"> <xsl:if test="position()=1"> SELECT DISTINCT sp.site_datatype_id FROM ref_hm_site_pcode sp WHERE sp.hm_site_code = '<xsl:value-ofselect='HM_SITE_CODE'/>' AND sp.hm_pcode = '<xsl:value-ofselect='HM_PCODE'/>' </xsl:if> </xsl:template>

However, instead of , we need to substitute a parameter, such as .

How can we do this?

If you have a top-level parameter declared in your stylesheet, such as:

<xsl:stylesheet ... > <!-- declare top-level $foo parameter, default value to 5 --> <xsl:param name="foo" select="5"/> <xsl:template match="/"> <xsl:if test="$foo=10"> :

Then you can use the following methods on to control parameters:

To set the parameter named to the number 10, use the following:

myStylesheet.setParam("foo","10");

To set to the string , you need to quote it:

myStylesheet.setParam("foo","'ten'");

If I need to pass parameters to the stylesheet in a Java program, what Java class must I use?

Currently, we use:

processXSL(XSLStylesheet xsl,XMLDocument xml)

What method canI use to pass the parameters?

See:

We used from , that explains how to use the XDK to retrieve XML data from Oracle and transform it to HTML.

We can generate the XML output file but when we try to generate the HTML output by using the file, , which has the following argument:

<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

it shows error XSL-1009 ATTRIBUTE 'XSL VERSION' NOT FOUND IN 'HTML'

  • What is the right argument for the XSL file? We tried and it works but the HTML output does not have any HTML tag at all, just pure data.
  • I have never seen the HTML output generated from the XMLParser so I do not know whether it will generate HTML tags for me automatically or not.

What should the HTML output file look like?

You must add attribute to your element.

Can you tell me what XPath expression I should use to retrieve only terminal child elements (that is, elements which don't have any child elements) from a specified element. For example, I want to use an XPath expression to return only the child elements highlighted in red below:

<TABLE> <ID>1</ID> <NAME>1</NAME> <SIZE>1</SIZE> <COLUMNS> <COLUMN> <ID>1</ID> <NAME>Customers</NAME> <COLUMN> <COLUMN> <ID>c</ID> <NAME>Categories</NAME> <COLUMN> <COLUMNS> <DATE_CREATED>01/10/2000</DATE_CREATED> </TABLE>

A possible solution is the following:

<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="TABLE"> <xsl:apply-templates select="child::*[not(child::*)]"/> </xsl:template> </xsl:stylesheet>

The expression you want is:

/TABLE/*[count(child::*) = 0]

or

/TABLE/*[not (child::*)]

You can omit the child axis, so above expression is the same as:

/TABLE/*[count(*) = 0]

or

/TABLE/*[not (*)]

We are merging an XML document with its XSL stylesheet. Child attributes are not being returned when they are using syntax of type:

<xsl:value-of select="Foo/Bar"/>

in the XSL document. This seems to work fine in other XML parsers including XML Spy and Stylus.

The XPath expression is only designed to select the value of the element contained in the element. It will return the concatenation of all text nodes in the nested content of that element, but certainly is not designed to select any text values in attributes. For this, you'd need the syntax: Foo/Bar/@SomeAttr to select one attribute and...

Foo/Bar/@* to select all the attributes of <Bar>.