Re: [xsl] read/write in the same xml file

Subject: Re: [xsl] read/write in the same xml file
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Jun 2003 15:17:12 -0400
At 06:11 AM 6/10/2003, you wrote:
what i need is to know how much characters i have write in the output file
each time, because i want to make a table of contents like this:
paragraph1  begining  end
---------     ------    ----
paragraph i  ------     ----

the begining and the end position are exprimed in characters.

so for this reason i want to use an extern file named compte.xml
which i will use in my stylesheet every time for knowing the position.

Ah, well you could pass your external filename in as a parameter at runtime, instead of hardcoding it.


As far as knowing how many characters precede a given position (say, the start of a paragraph), are you speaking of characters irrespective of markup, or characters including markup? That is, given

<text>
 <p>Here's paragraph one.</p>
 <p>Here's paragraph two.</p>
</text>

Do you want the first p to yield 0 (or perhaps 2 if you count the whitespace after the <text> start tag) and the second, 21 (the length of the first p)? Or do you want an absolute character offset including the characters that appear in the start tags "<text>", "<p>" and so on?

If the first, it can be done in XSLT, although it's not necessarily the best tool for the job. If you mean the second, XSLT is certainly *not* the tool for the job since the XSLT source tree (created by parsing the file) does not keep track of tags.

Please clarify.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread