[cxml-devel] cxml-stp usage
Steven Nunez
steve_nunez at yahoo.com
Sun Jun 10 07:51:34 UTC 2012
Greetings all,
I'm a bit stumped by some of the STP functions and usage. The documentation is, well, a bit sparse, so it's not clear whether there really is a bug or I'm mis-interpreting what I'm reading. Here is a simple function that should return all the child nodes of an element with the local-name of 'RegressionModel':
(defun function-name (document)
"Return the PMML model type of the document"
(stp:filter-recursively (stp:of-name "RegressionModel") (stp:first-child document)))
According to the documentation of filter-recursively:
Return a list of descendant nodes of node in pre-order, from which nodes that do not satisfy predicate have been removed.and that for of-name:
This function creates a test function for nodes of this name.
>
>The function returned will return T if the argument is an instance of attribute or element and has the specified local-name and namespace URI, and will return NIL otherwise.
>
>If local-name is nil, only the namespace URI is considered for comparison.
>
and here's the local snippet of the xmls that I'm trying to filter for:
#.(CXML-STP:ELEMENT
> #| :PARENT of type ELEMENT |#
> :ATTRIBUTES '(#.(CXML-STP:ATTRIBUTE
> #| :PARENT of type ELEMENT |#
> :VALUE "PolynomialRegression"
> :LOCAL-NAME "algorithmName")
> #.(CXML-STP:ATTRIBUTE
> #| :PARENT of type ELEMENT |#
> :VALUE "regression"
> :LOCAL-NAME "functionName")
> #.(CXML-STP:ATTRIBUTE
> #| :PARENT of type ELEMENT |#
> :VALUE "KNIME Polynomial Regression"
> :LOCAL-NAME "modelName")
> #.(CXML-STP:ATTRIBUTE
> #| :PARENT of type ELEMENT |#
> :VALUE "s_s_temp"
> :LOCAL-NAME "targetFieldName"))
> :BASE-URI "file://+/Users/nunez/src/lisp/pmml/polynomial-regression.xml"
> :CHILDREN '(#.(CXML-STP:TEXT
> #| :PARENT of type ELEMENT |#
> :DATA "
> ")So, there's an attribute with a local-name that matches the value in of-name. Why is this function always returning NIL?
Is stp stable enough for production use? It's been a while since it's been updated. I'm new to XML with LISP, so if there's a better documented or easier way to process these documents, happy to take a different route.
Finally, does anyone know why I need to pass the function the first child? Seem cxml-stp is getting tripped up on the first line of the xml file: <?xml version="1.0" encoding="UTF-8"?> and forcing me to manually grab the second element. Is there a convention or idiom I'm missing?
Sample file attached.
Cheers,
- Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20120610/121b197b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polynomial-regression.xml
Type: text/xml
Size: 3957 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20120610/121b197b/attachment.xml>
More information about the cxml-devel
mailing list