- From: Miguel Garcia <miguel.garcia@fundacionctic.org>
- Date: Mon, 18 Jun 2007 17:28:25 +0200
- To: <public-mobileok-checker@w3.org>
- Cc: Roland Gülle <roland@7val.com>
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 15:28:36 UTC