By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

docbook xslt bug: System.NullReferenceException: Object reference not set to an instance of an object

P: n/a
I have a docbook xml file, and am using standard docbook 1.61.3 xsl
stylesheets to do xhtml transform. Transform works fine when using
MSXML.

When I try to do the following using asp.net 1.1:

private void Page_Load(object sender, System.EventArgs e) {

// load content
XslTransform trans = new XslTransform();
trans.Load("../funcspec_common/docbook-xsl-1.61.3/xhtml/docbook.xsl");

XPathDocument doc = new
XPathDocument(Server.MapPath("content.xml"));

StringWriter sw2 = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(sw2); //Write to
StringWriter
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.Indentation = 4;

trans.Transform(doc,null,xmlWriter);
this.contentWriter.Text = sw2.ToString();
sw2.Close();
xmlWriter.Close();

}

</script>
<html>
<head>
<title>Functional Specs</title>
<link media="screen" href="../funcspec_common/examplesite1.css"
type="text/css" rel="stylesheet" />
</head>
<body>
<form method="post" runat="server">
<asp:literal id="contentWriter" Runat="server"></asp:literal>
</form>
</body>
</html>
I receive the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

The source code that generated this unhandled exception can only be
shown when compiled in debug mode. To enable this, please follow one
of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated
the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your
application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given
application to be compiled in debug mode. The first technique will
cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a
memory/performance overhead. You should make sure that an application
has debugging disabled before deploying into production scenario.

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
System.Xml.XPath.FilterQuery.SetXsltContext(XsltCo ntext input) +11
System.Xml.XPath.FilterQuery.SetXsltContext(XsltCo ntext input) +15
System.Xml.XPath.MergeFilterQuery.SetXsltContext(X sltContext input)
+25
System.Xml.XPath.CompiledXpathExpr.SetContext(XmlN amespaceManager
nsManager) +134
System.Xml.Xsl.Processor.GetCompiledQuery(Int32 key) +96
System.Xml.Xsl.ApplyTemplatesAction.Execute(Proces sor processor,
ActionFrame frame) +296
System.Xml.Xsl.ActionFrame.Execute(Processor processor) +24
System.Xml.Xsl.Processor.Execute() +79
System.Xml.Xsl.XslTransform.Transform(IXPathNaviga ble input,
XsltArgumentList args, XmlWriter output) +264
ASP.printable_html_aspx.Page_Load(Object sender, EventArgs e) +170
System.Web.UI.Control.OnLoad(EventArgs e) +55
System.Web.UI.Control.LoadRecursive() +27
System.Web.UI.Page.ProcessRequestMain() +731


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573
Nov 11 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
mike p. wrote:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl
stylesheets to do xhtml transform. Transform works fine when using
MSXML.


This is well-known (and confirmed) bug in XslTransform (both 1.0 and 1.1
affected), see
http://groups.google.com/groups?hl=e...549b001&rnum=2
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

P: n/a
The bug in the email thread pointed by Oleg was with cloning OR boolean
expressions in multiple threads. This is fixed in V1.1 SDK.

From Mike's call stack this looks like a different issue with XsltContext.
Can you share your XSLT with me so that I can take a look.

Thanks,
Prajakta Joshi (MS)

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/copyright.htm.
"Oleg Tkachenko" <ol***@multiconn.com> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
mike p. wrote:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl
stylesheets to do xhtml transform. Transform works fine when using
MSXML.
This is well-known (and confirmed) bug in XslTransform (both 1.0 and 1.1
affected), see

http://groups.google.com/groups?hl=e...549b001&rnum=2 --
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

P: n/a
I am using the standard docbook xhtml xslt - the most
recent version available on sourceforge. Thanks for your
help.
-----Original Message-----
The bug in the email thread pointed by Oleg was with cloning OR booleanexpressions in multiple threads. This is fixed in V1.1 SDK.
From Mike's call stack this looks like a different issue with XsltContext.Can you share your XSLT with me so that I can take a look.

Thanks,
Prajakta Joshi (MS)

--
This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified athttp://www.microsoft.com/info/copyright.htm.
"Oleg Tkachenko" <ol***@multiconn.com> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
mike p. wrote:
> I have a docbook xml file, and am using standard docbook 1.61.3 xsl > stylesheets to do xhtml transform. Transform works fine when using > MSXML.


This is well-known (and confirmed) bug in XslTransform (both 1.0 and 1.1 affected), see

http://groups.google.com/groups?hl=en&lr=&ie=UTF-

8&th=71929b2b7549b001&rnum=2
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #4

P: n/a
mike wrote:
I am using the standard docbook xhtml xslt - the most
recent version available on sourceforge. Thanks for your
help.

Ok, then provide your content.xml document for us to be able to
reproduce the problem.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #5

P: n/a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article SYSTEM "http://www.oasis-
open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY functionalareas
SYSTEM "functionalareas.xml">
]>
<article>
<title>
<abbrev/>Functional Spec</title>
<tocchap>
<tocentry/>
<toclevel1>
<tocentry id="a">A</tocentry>
</toclevel1>
<toclevel1>
<tocentry id="b">B</tocentry>
</toclevel1>
<toclevel1>
<tocentry id="c">C</tocentry>
</toclevel1>
<toclevel1>
<tocentry id="d">D</tocentry>
</toclevel1>
<toclevel1>
<tocentry id="e">E</tocentry>
</toclevel1>
<toclevel1>
<tocentry id="f">F</tocentry>
</toclevel1>
</tocchap>
<section id="cover_page">
<title/>
<mediaobject>
<imageobject>
<imagedata
fileref="../common/client_logo.eps" format="EPS"/>
</imageobject>
<imageobject>
<imagedata
fileref="../common/client_logo.gif" format="GIF"/>
</imageobject>
</mediaobject>
</section>
<section id="overview">
<title>Introduction</title>
<para>The purpose of this document is to
collect, analyze, and define the external behavior and
features for <abbrev/>, as well as nonfunctional
requirements, design constraints, and other factors
necessary to provide a complete, comprehensive description
of the software requirements. This document focuses on
functional and non-functional requirements rather than
technology, and is intended to answer questions relating
to what <abbrev/>should accomplish, and for whom. This
document describes both what needs are to be fulfilled and
how those needs are to be fulfilled through the functional
and non-functional requirements and use case
specifications.
</para>
<para>
This document serves as the basis for discussion and
agreement among the stakeholder communities for the
<abbrev/> project, which include:
</para>
<itemizedlist spacing="normal"
mark="bullet">
<listitem>
<simpara> The project
department for <abbrev/>, which serves as the proxy for
the customer and the user.</simpara>
</listitem>
<listitem>
<simpara> the project team
developing the application.</simpara>
</listitem>
<listitem>
<simpara> The management
team, which will be held responsible for the business
outcome of the endeavor.</simpara>
</listitem>
</itemizedlist>
<para>
It is important that the entire stakeholder community have
a shared understanding of the requirements of <abbrev/>. A
common understanding of requirements ensures that the
product described in this document is both what is desired
by business users and that what is desired is delivered by
the creative and technical teams. The completeness of this
document directly impacts the completeness, quality, and
timely delivery of the eventual product.
</para>
</section>
<section id="b">
<title>Client Development
Guidelines</title>
<para>
All development should follow standards outlined
in the Standards Version 2.0 document provided by
Genentech. This document outlines technical, creative, and
content standards.
</para>
<para>
<emphasis>Standards Version
2.0</emphasis>
<itemizedlist>
<listitem>
<simpara>
<ulink
url="../funcspec_common/website_standards2.htm"
type="popup">HTML Format</ulink>
</simpara>
</listitem>
<listitem>
<simpara>
<ulink
url="../funcspec_common/website_standards2.pdf"
type="popup">PDF Format</ulink>
</simpara>
</listitem>
</itemizedlist>
</para>
</section>
&functionalareas;
<section id="printabledocument">
<title>Printable Document</title>
<para>A printable version of these
specifications is available <ulink
url="printable_html.aspx" type="popup">in HTML
format</ulink>
</para>
</section>
</article>

<!-- functionalareas.xml -->
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by sadf (safd) -->
<section id="functionalareas">
<title>hello</title>
<para>hello</para>
</section>
-----Original Message-----
mike wrote:
I am using the standard docbook xhtml xslt - the most
recent version available on sourceforge. Thanks for your help.Ok, then provide your content.xml document for us to be

able toreproduce the problem.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #6

P: n/a
Hello!

Unable to reproduce unfortunately. When I run your document against docbook
xslt I got as expected old notorious one:

System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/docbook.xsl(24,2) :
---> System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/common/common.xsl(1554,10) :
---> System.Xml.Xsl.XsltException: '$years[1] + 1' is an invalid XPath
expression. ---> System.Xml.XPath.XPathException: XsltContext is needed for
this query because of an unknown function.
at System.Xml.XPath.VariableQuery.ReturnType()
at System.Xml.XPath.PositionQuery.ReturnType()
at System.Xml.XPath.FilterQuery.ReturnType()
at System.Xml.XPath.NumericExpr..ctor(Op op, IQuery opnd1, IQuery opnd2)
at System.Xml.XPath.QueryBuilder.ProcessOperator(Oper ator root, IQuery
qyInput, Boolean& cache, Boolean& position)
at System.Xml.XPath.QueryBuilder.ProcessNode(AstNode root, IQuery qyInput,
Int32 parent, AxisType parentaxis, Boolean& cache, Boolean& position)
at System.Xml.XPath.QueryBuilder.Build(AstNode root, String query)
at System.Xml.Xsl.Compiler.AddQuery(String xpathQuery, Boolean allowVar,
Boolean allowKey)

If I modify $years[1] + 1 to number($years[1]) + 1 at 1554 line of
common/common.xsl I get another (but similar) exception:

System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/docbook.xsl(32,2) :
---> System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/autoidx.xsl(36,4) :
---> System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.MergeFilterQuery.Clone()
at System.Xml.XPath.OrQuery.Clone()
at System.Xml.XPath.MethodOperand.Clone()
at System.Xml.XPath.LogicalExpr.Clone()
at System.Xml.XPath.BooleanFunctions.Clone()
at System.Xml.XPath.AndExpr.Clone()
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.QueryBuilder.ProcessFilter(Filter root, Boolean&
cache, Boolean& position)
....

That's deeply in autoidx.xsl, which probably nobody but Jeni Tennison
understands, in this crazy XPath expression:

<xsl:variable name="terms"
select="//indexterm[count(.|key('letter',translate(substring(normalize-space(concat(primary/@sortas,
primary[not(@sortas)])), 1, 1),
'abcdefghijklmnopqrstuvwxyz',

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[count(ancestor::node()|$scope) =
count(ancestor::node())][1]) = 1 and not(@class = 'endofrange')]"/>

Hope I'll find a time to debug it further...
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #7

P: n/a
Yes, I received the autoidx bug as well. I forgot to
mention that I changed the docbook stylesheet
number/string handling lines as detailed in:

http://groups.google.com/groups?hl=e...=UTF-8&oe=UTF-
8&threadm=e0HAV4iGDHA.2852%
40tk2msftngp13.phx.gbl&rnum=1&prev=/groups%3Fq%3Ddocbook%
2Basp.net%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%
26selm%3De0HAV4iGDHA.2852%2540tk2msftngp13.phx.gbl %26rnum%
3D1

with this patch, i no longer get the autoidx bug, just the
bug i originally posted.
-----Original Message-----
Hello!

Unable to reproduce unfortunately. When I run your document against docbookxslt I got as expected old notorious one:

System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/docbook.xsl (24,2) : ---> System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/common/common.xsl (1554,10) : ---> System.Xml.Xsl.XsltException: '$years[1] + 1' is an invalid XPathexpression. ---> System.Xml.XPath.XPathException: XsltContext is needed forthis query because of an unknown function.
at System.Xml.XPath.VariableQuery.ReturnType()
at System.Xml.XPath.PositionQuery.ReturnType()
at System.Xml.XPath.FilterQuery.ReturnType()
at System.Xml.XPath.NumericExpr..ctor(Op op, IQuery opnd1, IQuery opnd2) at System.Xml.XPath.QueryBuilder.ProcessOperator (Operator root, IQueryqyInput, Boolean& cache, Boolean& position)
at System.Xml.XPath.QueryBuilder.ProcessNode(AstNode root, IQuery qyInput,Int32 parent, AxisType parentaxis, Boolean& cache, Boolean& position) at System.Xml.XPath.QueryBuilder.Build(AstNode root, String query) at System.Xml.Xsl.Compiler.AddQuery(String xpathQuery, Boolean allowVar,Boolean allowKey)

If I modify $years[1] + 1 to number($years[1]) + 1 at 1554 line ofcommon/common.xsl I get another (but similar) exception:

System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/docbook.xsl (32,2) : ---> System.Xml.Xsl.XsltCompileException:
file:///D:/docbook/docbook-xsl-1.61.3/xhtml/autoidx.xsl (36,4) : ---> System.NullReferenceException: Object reference not set to an instanceof an object.
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.MergeFilterQuery.Clone()
at System.Xml.XPath.OrQuery.Clone()
at System.Xml.XPath.MethodOperand.Clone()
at System.Xml.XPath.LogicalExpr.Clone()
at System.Xml.XPath.BooleanFunctions.Clone()
at System.Xml.XPath.AndExpr.Clone()
at System.Xml.XPath.FilterQuery.Clone()
at System.Xml.XPath.QueryBuilder.ProcessFilter(Filter root, Boolean&cache, Boolean& position)
....

That's deeply in autoidx.xsl, which probably nobody but Jeni Tennisonunderstands, in this crazy XPath expression:

<xsl:variable name="terms"
select="//indexterm[count(.|key('letter',translate (substring(normalize-space(concat(primary/@sortas,primary[not(@sortas)])), 1, 1),
'abcdefghijklmnopqrstuvwxyz',

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[count(ancestor::node() |$scope) =count(ancestor::node())][1]) = 1 and not(@class = 'endofrange')]"/>
Hope I'll find a time to debug it further...
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.