Re: line number problem

> Good point. I suppose I had imagined that the XSLT would operate on a
> DOM that we manually build up in Java, and includes the real, original
> DOM that was parsed from the source document including line number
> info -- not a copy. Then the line-number-related methods should still
> work.
>
> But indeed, none of this works if you parse a moki document from
> scratch in an XSLT since the original line number info is lost. Which
> partially shoots its raison d'etre in the foot.
>
> Better ideas? Unless what I sketched out above works, we're getting
> more fenced in by using XSLT + moki by the day and think we need to
> think hard about what this approach is gaining versus costing before
> we go further.
I just tested some ideas, here my result:

Some ideas with rebuilding a Nodeset from a string with EXSLT don't  
work:
<xsl:for-each select="exsl:node-set($originalDocAsString)//xpath">
  <xsl:value-of select="saxon:line-number(.)" xmlns:saxon="http:// 
saxon.sf.net/"/>
</xsl:for-each>

But using the document function to reparse a document, works:
<xsl:for-each select="document('originalDocAsFileName)//xpath">
  <xsl:value-of select="saxon:line-number(.)" xmlns:saxon="http:// 
saxon.sf.net/"/>
</xsl:for-each>

It is possible, to access to the original (unparsed) doc with the  
document function?

If so, and the reference to this doc is in the moki document, there  
is a solution:
when reporting a line number:
* call a template with the context you want to report
* this template:
   * gets the original document reference
   * generates the 'html doc xpath' from the current xpath
   * gets the line number with the original doc ref and the generated  
xpath
   * returns the line number

Cheers,
  Roland

Received on Friday, 13 July 2007 13:44:24 UTC