Dear Marco,
Thank you very much for the suggestion, I will put it into the wiki when
I get around to writing a page about stand-off markup, so that others
may use it too. Although the servlet didn't work for me, it still looks
like a good foundation, judging from the description.
And now, tadammm, let me tell you that I have found a promising
implementation of xpointer(), in one of the standard parsers: xmllint! :-)
Below, I include a little test case that can be a beginning for
exploring this implementation. A few corrections in chapter 16 of the
Guidelines are in order, because some of the examples there don't follow
the W3C draft (which admittedly seems a bit unclear at places) -- for
example, string-range() takes two obligatory arguments, rather than one,
as the Guidelines suggest (the string must be there, even if it's
empty). OTOH, range() only takes one argument at most.
The test case is simple, because I need some sleep :-) Here it is:
include.xml:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,'',1,47)[1])"/></p>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,'',50,22)[1])"/></p>
</body>
<!-- can't use element() as the 1st arg;
need the 2nd argument, even if it's empty;
the '[1]' is mandatory - it has the effect of anchoring the calculations
to the position before the first character of the entire string -->
-----------------------------------------------------------
source.xml (borrowed from the Guidelines):
<?xml version="1.0" encoding="UTF-8"?>
<div><p>To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.
The revery alone will do,
If bees are few</p></div>
Invoke it with: xmllint --xinclude include.xml
This include.xml actually causes a little recoverable error, because of
the empty string, which matches *everywhere* between characters (this is
why the predicate '[1]' is needed). I experimented with placing a
designated character, e.g.   (non-breaking space) as the first
character in source.xml, to act as the anchor. If you do so, include.xml
should become:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<head>--------------------------------</head>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,' ',3,48)[1])"/></p>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,' ',52,22)[1])"/></p>
</body>
(no errors in this case)
Well, stand-off markup appears to have a chance to start working without
extra tools at last :-)
Cheers,
Piotr
PS. xmllint is part of libxml2: http://xmlsoft.org/ and any Linux distro.
Marco Petris writes:
> Dear Piotr,
>
> before we decided to use the <ptr>-element I had the idea to treat the whole
> plain-text as the content of one xml-element and to use string-range for
> targeting.
> So I made a search for string-range implementations but as I'm in the Java
> world right now, I looked for Java solutions only, so I don't know if this
> link will really be helpful to you:
> http://www.cs.unibo.it/projects/xslt%2B%2B/XPointerTest.html
> It is a Java implementation of XPointer which includes the drafts as well.
> It's the only one I found. The source code is available but I don't know
> anything about the quality of this library and the work on the surrounding
> project XSLT++ (http://www.cs.unibo.it/projects/xslt%2B%2B/) seems to be
> completed...
>
> Greetings and good luck
>
> Marco
>
>
>
|