W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > June 2007

ACTION-512 - Research getting line and column information from XPath

From: Roland Gülle <roland@7val.com>
Date: Mon, 18 Jun 2007 09:42:23 +0200
Message-Id: <8519497C-7150-481C-8177-032A0B65D4AD@7val.com>
To: public-mobileok-checker@w3.org

It seems that there are no XPath column/line Information functions.

But with Xalan, it seems that we can use the source location feature  
[1] that provide the SourceLocator.
With the SourceLocator, we can use the NodeInfo lineNumber Xalan  
function [2].
I try to use this direct in the XSLT at the command line, but I get  
always the error:
'There is more than one method matching the function call  
info:lineNumber, and there is insufficient type information to  
determine which one should be used'
Add the context or nodeList XPath, won't help, so it seems that there  
are problems with running this on the command-line.

Here my test XSLT:
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:info="org.apache.xalan.lib.NodeInfo"
		extension-element-prefixes="info">

		<xsl:template match="/">
			<xsl:value-of select="info:lineNumber(node())"/>
		</xsl:template>
</xsl:stylesheet>

It is only a command line problem?
(I never used Xalan functions in XSLT before, but I noticed in the  
first CachingTest.xsl that Sean has used this - could someone help me  
at this problem?)

Another resolution could be Expat and GetCurrentColumnNumber /  
GetCurrentLineNumber, but using the Xalan Source Locator seems to be  
the preferred way.

  Roland


[1] http://xml.apache.org/xalan-j/features.html#source_location
[2] http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ 
NodeInfo.html#lineNumber(org.apache.xalan.extensions.ExpressionContext)
Received on Monday, 18 June 2007 07:42:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:13:03 GMT