1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-08-07 10:42:55 +03:00

Added a link to ScrollKeeper, Daniel

This commit is contained in:
Daniel Veillard
2002-02-22 20:12:19 +00:00
parent 3b571056b7
commit ac76027718
4 changed files with 147 additions and 148 deletions

View File

@@ -104,8 +104,7 @@ A:link, A:visited, A:active { text-decoration: underline }
provides libxml/libxslt <a href="http://www.rexx.com/~dkuhlman">wrappers
for Python</a>
</li>
<li>Steve Ball and contributors maintains
<a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
<li>Steve Ball and contributors maintains <a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a>
</li>
</ul>

View File

@@ -111,6 +111,9 @@ few pointers and informations which may be helpful:</p>
<li>Linux Documentation Project <a href="http://www.linuxdoc.org/HOWTO/mini/DocBook-Install/">
DocBook-Install-mini-HOWTO</a>
</li>
<li>ScrollKeeper the open documentation cataloging project has a <a href="http://scrollkeeper.sourceforge.net/docbook.shtml">DocBook
section</a>
</li>
</ul>
<p>Do not use the --docbook option of xsltproc to process XML DocBook
documents, this option is only intended to provide some (limited) support of

View File

@@ -84,7 +84,7 @@ or libxslt wrappers or bindings:</p>
<a href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">Matt
Sergeant</a>
developped <a href="http://axkit.org/download/">XML::LibXML and
XML::LibXSLT</a>, a perl wrapper for libxml2/libxslt as part of the <a href="http://axkit.com/">AxKit XML application server</a>
XML::LibXSLT</a>, a perl wrapper for libxml2/libxslt as part of the <a href="http://axkit.com/">AxKit XML application server</a>
</li>
<li>
<a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>
@@ -95,13 +95,11 @@ or libxslt wrappers or bindings:</p>
<li>Wai-Sun &quot;Squidster&quot; Chia provides <a href="http://www.rubycolor.org/arc/redist/">bindings for Ruby</a> and
libxml2 bindings are also available in Ruby through the <a href="http://libgdome-ruby.berlios.de/">libgdome-ruby</a> module
maintained by Tobias Peters.</li>
<li>Steve Ball and contributors maintains
<a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
<li>Steve Ball and contributors maintains <a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a>
</li>
</ul>
<p>The libxslt Python module depends on the <a href="http://xmlsoft.org/python.html">libxml2 Python</a> module.
</p>
<p>The libxslt Python module depends on the <a href="http://xmlsoft.org/python.html">libxml2 Python</a> module.</p>
<p>The distribution includes a set of Python bindings, which are garanteed to
be maintained as part of the library in the future, though the Python
interface have not yet reached the maturity of the C API. The distribution
@@ -109,8 +107,8 @@ includes a set of examples and regression tests for the python bindings in
the <code>python/tests</code> directory. Here are some excepts from those
tests:</p>
<h3>basic.py:</h3>
<p>This is a basic test of XSLT interfaces: loading a stylesheet and
a document, transforming the document and saving the result.</p>
<p>This is a basic test of XSLT interfaces: loading a stylesheet and a
document, transforming the document and saving the result.</p>
<pre>import libxml2
import libxslt
@@ -127,28 +125,32 @@ for the operations on XML trees. Let's have a look at the objects manipulated
in that example and how is the processing done:</p>
<ul>
<li>
<code>styledoc</code>: is a libxml2 document tree. It is obtained by
parsing the XML file &quot;test.xsl&quot; containing the stylesheet.</li>
<code>styledoc</code>
: is a libxml2 document tree. It is obtained by parsing the XML file
&quot;test.xsl&quot; containing the stylesheet.</li>
<li>
<code>style</code>: this is a precompiled stylesheet ready to be used
by the following transformations (note the plural form, multiple
transformations can resuse the same stylesheet).</li>
<code>style</code>
: this is a precompiled stylesheet ready to be used by the following
transformations (note the plural form, multiple transformations can
resuse the same stylesheet).</li>
<li>
<code>doc</code>: this is the document to apply the transformation to.
In this case it is simply generated by parsing it from a file but any
other processing is possible as long as one get a libxml2 Doc. Note
that HTML tree are suitable for XSLT processing in libxslt. This is
actually how this page is generated !</li>
<code>doc</code>
: this is the document to apply the transformation to. In this case it is
simply generated by parsing it from a file but any other processing is
possible as long as one get a libxml2 Doc. Note that HTML tree are
suitable for XSLT processing in libxslt. This is actually how this page
is generated !</li>
<li>
<code>result</code>: this is a document generated by applying the
stylesheet to the document. Note that some of the stylesheet informations
may be related to the serialization of that document and as in this
example a specific saveResultToFilename() method of the stylesheet
should be used to save it to a file (in that case to &quot;foo&quot;).</li>
<code>result</code>
: this is a document generated by applying the stylesheet to the
document. Note that some of the stylesheet informations may be related to
the serialization of that document and as in this example a specific
saveResultToFilename() method of the stylesheet should be used to save it
to a file (in that case to &quot;foo&quot;).</li>
</ul>
<p>Also note the need to explicitely deallocate documents with freeDoc()
except for the stylesheet document which is freed when its compiled form
is garbage collected.</p>
except for the stylesheet document which is freed when its compiled form is
garbage collected.</p>
<h3>extfunc.py:</h3>
<p>This one is a far more complex test. It shows how to modify the behaviour
of an XSLT transformation by passing parameters and how to extend the XSLT
@@ -175,25 +177,22 @@ def f(ctx, str):
return string.upper(str)
libxslt.registerExtModuleFunction(&quot;foo&quot;, &quot;http://example.com/foo&quot;, f)</pre>
<p> This code defines and register an extension function. Note that the
<p>This code defines and register an extension function. Note that the
function can be bound to any name (foo) and how the binding is also
associated to a namespace name &quot;http://example.com/foo&quot;. From an
XSLT point of view the function just returns an upper case version of the
string passed as a parameter. But the first part of the function also
read some contextual information from the current XSLT processing environement,
in that case it looks for the current insertion node in the resulting output
(either the resulting document or the Result Value Tree being generated), and
saves it to a global variable for checking that the access actually worked.
</p>
<p> For more informations on the xpathParserContext and transformContext
associated to a namespace name &quot;http://example.com/foo&quot;. From an XSLT point
of view the function just returns an upper case version of the string passed
as a parameter. But the first part of the function also read some contextual
information from the current XSLT processing environement, in that case it
looks for the current insertion node in the resulting output (either the
resulting document or the Result Value Tree being generated), and saves it to
a global variable for checking that the access actually worked.</p>
<p>For more informations on the xpathParserContext and transformContext
objects check the <a href="internals.html">libray internals description</a>.
The pctxt is actually an object from a class derived from the
libxml2.xpathParserContext() with just a couple more properties including
the possibility to look up the XSLT transformation context from the XPath
context.
</p>
<pre>
styledoc = libxml2.parseDoc(&quot;&quot;&quot;
libxml2.xpathParserContext() with just a couple more properties including the
possibility to look up the XSLT transformation context from the XPath
context.</p>
<pre>styledoc = libxml2.parseDoc(&quot;&quot;&quot;
&lt;xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:foo='http://example.com/foo'
@@ -205,34 +204,27 @@ styledoc = libxml2.parseDoc(&quot;&quot;&quot;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
&quot;&quot;&quot;)</pre>
<p> Here is a simple example of how to read an XML document from a python
string with libxml2. Note how this stylesheet:
</p>
<p>Here is a simple example of how to read an XML document from a python
string with libxml2. Note how this stylesheet:</p>
<ul>
<li> Uses a global parameter <code>bar</code>
</li>
<li> Reference the extension function f
</li>
<li> how the Namespace name &quot;http://example.com/foo&quot; has to be bound to
a prefix
</li>
<li> how that prefix is excluded from the output
</li>
<li> how the function is called from the select
<li>Uses a global parameter <code>bar</code>
</li>
<li>Reference the extension function f</li>
<li>how the Namespace name &quot;http://example.com/foo&quot; has to be bound to a
prefix</li>
<li>how that prefix is excluded from the output</li>
<li>how the function is called from the select</li>
</ul>
<pre>style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc(&quot;&lt;doc/&gt;&quot;)
result = style.applyStylesheet(doc, { &quot;bar&quot;: &quot;'success'&quot; })
style.freeStylesheet()
doc.freeDoc()</pre>
<p> that part is identical, to the basic example except that the
transformation is passed a dictionnary of parameters. Note that the
string passed &quot;success&quot; had to be quoted, otherwise it is interpreted
as an XPath query for the childs of root named &quot;success&quot;.
</p>
<pre>
root = result.children
<p>that part is identical, to the basic example except that the
transformation is passed a dictionnary of parameters. Note that the string
passed &quot;success&quot; had to be quoted, otherwise it is interpreted as an XPath
query for the childs of root named &quot;success&quot;.</p>
<pre>root = result.children
if root.name != &quot;article&quot;:
print &quot;Unexpected root node name&quot;
sys.exit(1)
@@ -243,27 +235,20 @@ if nodeName != 'article':
print &quot;The function callback failed to access its context&quot;
sys.exit(1)
result.freeDoc()
</pre>
<p> That part just verifies that the transformation worked, that the parameter
result.freeDoc()</pre>
<p>That part just verifies that the transformation worked, that the parameter
got properly passed to the engine, that the function f() got called and that
it properly accessed the context to find the name of the insertion node.
</p>
it properly accessed the context to find the name of the insertion node.</p>
<h3>pyxsltproc.py:</h3>
<p> this module is a bit too long to be described there but it is basically
a rewrite of the xsltproc command line interface of libxslt in Python. It
<p>this module is a bit too long to be described there but it is basically a
rewrite of the xsltproc command line interface of libxslt in Python. It
provides nearly all the functionalities of xsltproc and can be used as a base
module to write Python customized XSLT processors. One of the thing
to notice are:
</p>
module to write Python customized XSLT processors. One of the thing to notice
are:</p>
<pre>libxml2.lineNumbersDefault(1)
libxml2.substituteEntitiesDefault(1)
</pre>
<p> those two calls in the main() function are needed to force the libxml2
processor to generate DOM trees compliant with the XPath data model.
</p>
libxml2.substituteEntitiesDefault(1)</pre>
<p>those two calls in the main() function are needed to force the libxml2
processor to generate DOM trees compliant with the XPath data model.</p>
<p><a href="mailto:daniel@veillard.com">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@@ -602,6 +602,9 @@ few pointers and informations which may be helpful:</p>
<li>Linux Documentation Project <a
href="http://www.linuxdoc.org/HOWTO/mini/DocBook-Install/">
DocBook-Install-mini-HOWTO</a></li>
<li>ScrollKeeper the open documentation cataloging project has a <a
href="http://scrollkeeper.sourceforge.net/docbook.shtml">DocBook
section</a></li>
</ul>
<p>Do not use the --docbook option of xsltproc to process XML DocBook
@@ -664,7 +667,7 @@ or libxslt wrappers or bindings:</p>
href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">Matt
Sergeant</a>
developped <a href="http://axkit.org/download/">XML::LibXML and
XML::LibXSLT</a>, a perl wrapper for libxml2/libxslt as part of the <a
XML::LibXSLT</a>, a perl wrapper for libxml2/libxslt as part of the <a
href="http://axkit.com/">AxKit XML application server</a></li>
<li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>
provides and earlier version of the libxml/libxslt <a
@@ -677,12 +680,14 @@ or libxslt wrappers or bindings:</p>
libxml2 bindings are also available in Ruby through the <a
href="http://libgdome-ruby.berlios.de/">libgdome-ruby</a> module
maintained by Tobias Peters.</li>
<li>Steve Ball and contributors maintains
<a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a>
<li>Steve Ball and contributors maintains <a
href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a></li>
</ul>
<p>The libxslt Python module depends on the <a href="http://xmlsoft.org/python.html">libxml2 Python</a> module.
<p>The libxslt Python module depends on the <a
href="http://xmlsoft.org/python.html">libxml2 Python</a> module.</p>
<p>The distribution includes a set of Python bindings, which are garanteed to
be maintained as part of the library in the future, though the Python
interface have not yet reached the maturity of the C API. The distribution
@@ -692,8 +697,8 @@ tests:</p>
<h3>basic.py:</h3>
<p>This is a basic test of XSLT interfaces: loading a stylesheet and
a document, transforming the document and saving the result.</p>
<p>This is a basic test of XSLT interfaces: loading a stylesheet and a
document, transforming the document and saving the result.</p>
<pre>import libxml2
import libxslt
@@ -710,28 +715,33 @@ result.freeDoc()</pre>
for the operations on XML trees. Let's have a look at the objects manipulated
in that example and how is the processing done:</p>
<ul>
<li><code>styledoc</code>: is a libxml2 document tree. It is obtained by
parsing the XML file "test.xsl" containing the stylesheet.</li>
<li><code>style</code>: this is a precompiled stylesheet ready to be used
by the following transformations (note the plural form, multiple
transformations can resuse the same stylesheet).</li>
<li><code>doc</code>: this is the document to apply the transformation to.
In this case it is simply generated by parsing it from a file but any
other processing is possible as long as one get a libxml2 Doc. Note
that HTML tree are suitable for XSLT processing in libxslt. This is
actually how this page is generated !</li>
<li><code>result</code>: this is a document generated by applying the
stylesheet to the document. Note that some of the stylesheet informations
may be related to the serialization of that document and as in this
example a specific saveResultToFilename() method of the stylesheet
should be used to save it to a file (in that case to "foo").</li>
<li><code>styledoc</code>
: is a libxml2 document tree. It is obtained by parsing the XML file
"test.xsl" containing the stylesheet.</li>
<li><code>style</code>
: this is a precompiled stylesheet ready to be used by the following
transformations (note the plural form, multiple transformations can
resuse the same stylesheet).</li>
<li><code>doc</code>
: this is the document to apply the transformation to. In this case it is
simply generated by parsing it from a file but any other processing is
possible as long as one get a libxml2 Doc. Note that HTML tree are
suitable for XSLT processing in libxslt. This is actually how this page
is generated !</li>
<li><code>result</code>
: this is a document generated by applying the stylesheet to the
document. Note that some of the stylesheet informations may be related to
the serialization of that document and as in this example a specific
saveResultToFilename() method of the stylesheet should be used to save it
to a file (in that case to "foo").</li>
</ul>
<p>Also note the need to explicitely deallocate documents with freeDoc()
except for the stylesheet document which is freed when its compiled form
is garbage collected.</p>
except for the stylesheet document which is freed when its compiled form is
garbage collected.</p>
<h3>extfunc.py:</h3>
<p>This one is a far more complex test. It shows how to modify the behaviour
of an XSLT transformation by passing parameters and how to extend the XSLT
engine with functions defined in python:</p>
@@ -757,23 +767,24 @@ def f(ctx, str):
return string.upper(str)
libxslt.registerExtModuleFunction("foo", "http://example.com/foo", f)</pre>
<p> This code defines and register an extension function. Note that the
<p>This code defines and register an extension function. Note that the
function can be bound to any name (foo) and how the binding is also
associated to a namespace name "http://example.com/foo". From an
XSLT point of view the function just returns an upper case version of the
string passed as a parameter. But the first part of the function also
read some contextual information from the current XSLT processing environement,
in that case it looks for the current insertion node in the resulting output
(either the resulting document or the Result Value Tree being generated), and
saves it to a global variable for checking that the access actually worked.
<p> For more informations on the xpathParserContext and transformContext
associated to a namespace name "http://example.com/foo". From an XSLT point
of view the function just returns an upper case version of the string passed
as a parameter. But the first part of the function also read some contextual
information from the current XSLT processing environement, in that case it
looks for the current insertion node in the resulting output (either the
resulting document or the Result Value Tree being generated), and saves it to
a global variable for checking that the access actually worked.</p>
<p>For more informations on the xpathParserContext and transformContext
objects check the <a href="internals.html">libray internals description</a>.
The pctxt is actually an object from a class derived from the
libxml2.xpathParserContext() with just a couple more properties including
the possibility to look up the XSLT transformation context from the XPath
context.
<pre>
styledoc = libxml2.parseDoc("""
libxml2.xpathParserContext() with just a couple more properties including the
possibility to look up the XSLT transformation context from the XPath
context.</p>
<pre>styledoc = libxml2.parseDoc("""
&lt;xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:foo='http://example.com/foo'
@@ -785,28 +796,28 @@ styledoc = libxml2.parseDoc("""
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
""")</pre>
<p> Here is a simple example of how to read an XML document from a python
string with libxml2. Note how this stylesheet:
<ul>
<li> Uses a global parameter <code>bar</code>
<li> Reference the extension function f
<li> how the Namespace name "http://example.com/foo" has to be bound to
a prefix
<li> how that prefix is excluded from the output
<li> how the function is called from the select
</ul>
<p>Here is a simple example of how to read an XML document from a python
string with libxml2. Note how this stylesheet:</p>
<ul>
<li>Uses a global parameter <code>bar</code></li>
<li>Reference the extension function f</li>
<li>how the Namespace name "http://example.com/foo" has to be bound to a
prefix</li>
<li>how that prefix is excluded from the output</li>
<li>how the function is called from the select</li>
</ul>
<pre>style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc("&lt;doc/&gt;")
result = style.applyStylesheet(doc, { "bar": "'success'" })
style.freeStylesheet()
doc.freeDoc()</pre>
<p> that part is identical, to the basic example except that the
transformation is passed a dictionnary of parameters. Note that the
string passed "success" had to be quoted, otherwise it is interpreted
as an XPath query for the childs of root named "success".
<pre>
root = result.children
<p>that part is identical, to the basic example except that the
transformation is passed a dictionnary of parameters. Note that the string
passed "success" had to be quoted, otherwise it is interpreted as an XPath
query for the childs of root named "success".</p>
<pre>root = result.children
if root.name != "article":
print "Unexpected root node name"
sys.exit(1)
@@ -817,23 +828,24 @@ if nodeName != 'article':
print "The function callback failed to access its context"
sys.exit(1)
result.freeDoc()
</pre>
<p> That part just verifies that the transformation worked, that the parameter
result.freeDoc()</pre>
<p>That part just verifies that the transformation worked, that the parameter
got properly passed to the engine, that the function f() got called and that
it properly accessed the context to find the name of the insertion node.
it properly accessed the context to find the name of the insertion node.</p>
<h3>pyxsltproc.py:</h3>
<p> this module is a bit too long to be described there but it is basically
a rewrite of the xsltproc command line interface of libxslt in Python. It
<p>this module is a bit too long to be described there but it is basically a
rewrite of the xsltproc command line interface of libxslt in Python. It
provides nearly all the functionalities of xsltproc and can be used as a base
module to write Python customized XSLT processors. One of the thing
to notice are:
module to write Python customized XSLT processors. One of the thing to notice
are:</p>
<pre>libxml2.lineNumbersDefault(1)
libxml2.substituteEntitiesDefault(1)
</pre>
<p> those two calls in the main() function are needed to force the libxml2
processor to generate DOM trees compliant with the XPath data model.
libxml2.substituteEntitiesDefault(1)</pre>
<p>those two calls in the main() function are needed to force the libxml2
processor to generate DOM trees compliant with the XPath data model.</p>
<h2><a name="Internals">Library internals</a></h2>
@@ -1769,9 +1781,9 @@ close the connection to the database to keep the same example.</p>
<li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>
provides libxml/libxslt <a href="http://www.rexx.com/~dkuhlman">wrappers
for Python</a></li>
<li>Steve Ball and contributors maintains
<a href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a>
<li>Steve Ball and contributors maintains <a
href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings for
Tcl</a></li>
</ul>
<p>I'm still waiting for someone to contribute a simple XSLT processing