Modifing parsed tree.
Radek Hnilica <[email protected]>
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Message-ID | <20040512181530.GD4833@yoda> |
Hello, I have some question.
First I want a introduce my "work". I'm using for some time xsltproc
in my DocBook processing machinery. I switch to int in some of my
"Books", because they are a huge and Saxon crashes on it. So xsltproc
passed testing time.
But xsltproc does not implement some extensions, Norman use in his
stylesheets. In the extension/xsltproc directory there are some
pieces of code which in combination with Python extend the xsltproc.
But those are old and not usefull. So I choose my own way. The WAY.
I start looking into xsltproc and exslt library. And I plan, I plan
write docbook extension to exslt library. I'm just standing before
the mountain and trying do first steps. May be I do not succeed, but
I'll try it.
So first work is to build TableAdjustColumnWidths function. So I
wrote some code only to see if I'm on right way and able to write some
extension.
The function does nothing now, I'm looking only if it do not breaks
other things.
/**
* exsltDBTableAdjustColumnWidths
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
*/
static void
exsltDBTableAdjustColumnWidths (xmlXPathParserContextPtr ctxt, int nargs) {
xmlNodeSetPtr cols;
int i;
dump_xmlXPathParserContext(ctxt, DUMP_DEEP, "ctxt", "context before any processing", 0);
#ifdef WITH_XSLT_DEBUG_FUNCTION
xsltGenericDebug(xsltGenericDebugContext,
"libxslt:exsltDBTableAdjustColumnWidths() called with %d args\n", nargs);
#endif
/* The number of passed arguments should be one. */
if (nargs != 1) xmlXPathSetArityError(ctxt); /* check the count */
/* Geting arguments from stack:
* I do not found function for poping XSLT_TREE object from
* argument stack. The PopNodeSet isn't good way how to get
* it.
* ERROR:cols = xmlXPathPopNodeSet(ctxt);
* So I access the value directly from XPathParserContext
* structure without modifiing the structure.
*/
//cols = ctxt->value;
cols = valuePop(ctxt); // :) so I found the right way, I hope.
dump_xmlXPathObject(cols, DUMP_DEEP, "cols", "Poped nodeset from ctxt", 0);
dump_xmlXPathParserContext(ctxt, DUMP_DEEP, "ctxt", "After PopNodeSet", 0);
if(xmlXPathCheckError(ctxt)) {
xsltGenericError(xsltGenericErrorContext,
"DB:TableAdjustColumnWidths: XPathCheckError\n");
return;
}
fprintf(stderr, "DEBUG: number of nodes in cols = %d\n", cols->nodeNr);
// FIXME: Go through all columns and implement the body of the
// TableAdjustColumnWidths
for (i=1; i<cols->nodeNr; i++) {
//col = ns->nodeTab[i];
}
/* Return columns */
valuePush(ctxt, cols);
} /* exsltDBTableAdjustColumnWidths */
For now it does not break things as I see. But ...
There is in documentation
http://xmlsoft.org/html/libxml-xpath.html#XPATH_XSLT_TREE some comment
there:
XPATH_XSLT_TREE = 9 : An XSLT value tree, non modifiable
And I'm not sure what to do with it. Firstly I think that I simply
traverse the tree and do necessary modification as the DocBook
stylesheet needs. But now I'm not sure if it's the right way.
So. Am I allowed to make sillently some "minor" modification of parsed
tree, or have I construct completly new tree following the original
parsed tree?
If I have construct new tree, can someone point me to code which
construct some.
--
Please feel free to flame me with "RTFM", just as long as you tell me
where in TFM I have to R.
Radek Hnilica <Radek.Hnilica at Moraviapress dot CZ>
Radek Hnilica <Radek at Hnilica dot CZ> http://www.hnilica.cz
==============================================================
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
... so turn back ... Now!
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAomnC04obroM0taURAs2qAJ92ODgbSHCWoYUL0aWmIp/by6fGwACgv68C oKwkNF3mfNg99jggbVFsX08= =1o/v -----END PGP SIGNATURE-----