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

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

From: Sean Owen <srowen@google.com>
Date: Mon, 18 Jun 2007 13:33:17 -0400
Message-ID: <e920a71c0706181033m4560cb08v46822003bd955830@mail.gmail.com>
To: "Roland Gülle" <roland@7val.com>
Cc: "Miguel Garcia" <miguel.garcia@fundacionctic.org>, public-mobileok-checker@w3.org
I'm not against that, but two things come to mind:

1) Does this work in Java, not just XSLT? remember we do have some
Java code here too. :)
2) Are we really sure we won't need any XSLT 2.0? seems like we're
doing so much in XSLT that we'd want all the features we can get. Like
the ones we were already using!
3) Saxon also already supports line numbers in a very similar way.

I'm pretty sure we can get line/col info into the DOM itself using
Xerces. Well, we're trying that now. Accessing it is just a matter of
downcasting nodes and accessing Xerces-specific methods, which
*should* work in XSLT too. Again, to be tried.

Sean

On 6/18/07, Roland Gülle <roland@7val.com> wrote:
>
> Hi Miguel,
>
> Thanks for your help - it works!
> I used the saxon.jar instead of the xalan.jar - sorry for this
> confusion!
>
> My xalan.jar don't like the xpath-default-namespace, it is correct
> that Xalan only supports XSLT 1.0?
> I downgraded the first test to XSLT 1.0 and and works fine - line and
> columns, great!
>
> Should we downgrade the XSLTs to 1.0 and use Xalan instead of Saxon?
>
>   Roland
>
>
>
> Am 18.06.2007 um 17:28 schrieb Miguel Garcia:
>
> > Hello,
> >
> > I have just managed to work Xalan lineNumber function. I view an
> > example of using it at apache mailing-list [1] and they use the .
> > (dot) operator instead of node() as parameter of lineNumber
> > function. I just made a basic example and it worked fine.
> >
> > CommandLine:
> > java -jar xalan.jar org.apache.xalan.xslt.Process -L -IN temp/
> > source.xml -XSL temp/xslt.xsl
> >
> > Xsl:
> > <?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:apply-templates/>
> >               </xsl:template>
> >
> >               <xsl:template match="//two_one">
> >                       <xsl:value-of select="name()"/>
> >                       <xsl:text> line: </xsl:text>
> >                       <xsl:value-of select="info:lineNumber(.)"/>
> >               </xsl:template>
> > </xsl:stylesheet>
> >
> > Xml:
> > <root>
> >       <one />
> >       <two>
> >               <two_one>Texto</two_one>
> >       </two>
> > </root>
> >
> > Miguel
> >
> > [1] http://mail-archives.apache.org/mod_mbox/xml-xalan-cvs/
> > 200202.mbox/%3C20020212183816.82831.qmail@icarus.apache.org%3E
> >
> >>> -----Mensaje original-----
> >>> De: public-mobileok-checker-request@w3.org [mailto:public-mobileok-
> >>> checker-request@w3.org] En nombre de Roland Gülle
> >>> Enviado el: lunes, 18 de junio de 2007 9:42
> >>> Para: public-mobileok-checker@w3.org
> >>> Asunto: ACTION-512 - Research getting line and column information
> >>> from
> >>> XPath
> >>>
> >>>
> >>> 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 17:33:35 GMT

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