<html><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:8pt"><div><span><div><span>Hi David,</span></div><div><span><br></span></div><div><span>Right, your explanation makes it clear. What's the convention/best practice/idiom for picking out the namespaces? Would be a bit repetitious to keep typing that out.</span></div><div><span><br></span></div><div><span>Regards,</span></div><div><span><span class="Apple-tab-span" style="white-space: pre; "> </span>- Steve</span></div><div><span><br></span></div></span></div><div><br></div> <div style="font-size: 8pt; font-family: verdana, helvetica, sans-serif; "> <div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> David Lichteblau <david@lichteblau.com><br> <b><span style="font-weight:
bold;">To:</span></b> "cxml-devel@common-lisp.net" <cxml-devel@common-lisp.net> <br> <b><span style="font-weight: bold;">Sent:</span></b> Sunday, June 10, 2012 8:49 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [cxml-devel] cxml-stp usage<br> </font> </div> <br>
Hi,<br><br>Quoting Steven Nunez (<a ymailto="mailto:steve_nunez@yahoo.com" href="mailto:steve_nunez@yahoo.com">steve_nunez@yahoo.com</a>):<br>> Greetings all,<br>> <br>> 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':<br>> <br>> (defun function-name (document)<br>> "Return the PMML model type of the document"<br>> (stp:filter-recursively (stp:of-name "RegressionModel") (stp:first-child document)))<br><br>The call to OF-NAME is the problem, it needs to be<br> (stp:of-name "RegressionModel" "http://www.dmg.org/PMML-4_0")<br>because:<br><br>> According to the documentation of filter-recursively:<br>> 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:<br>> This function creates a test function for nodes of this name.<br>> ><br>> >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.<br>> ><br>> >If local-name is nil, only the namespace URI is considered for comparison.<br><br>your element is in the <a href="http://www.dmg.org/PMML-4_0" target="_blank">http://www.dmg.org/PMML-4_0</a> namespace, whereas you<br>specified the empty namespace.<br><br>Roughly speaking,<br> local-name == SYMBOL-NAME<br> namespace-uri == SYMBOL-PACKAGE<br><br>I.e. just like distinct symbols in different packages have got nothing<br>to do with each other just because they happen to have the same<br>SYMBOL-NAME in Lisp,
similarly in XML, two elements with the same<br>local-name but a different namespace are considered distinct.<br><br>> and here's the local snippet of the xmls that I'm trying to filter for:<br>[...]<br>> So, there's an attribute with a local-name that matches the value in<br>> of-name. Why is this function always returning NIL?<br><br>An element with that local-name, right?<br><br>> Is stp stable enough for production use? It's been a while since it's<br>> been updated. I'm new to XML with LISP, so if there's a better<br>> documented or easier way to process these documents, happy to take a<br>> different route.<br><br>I think STP was pretty much finished when it was first written, because<br>it is basically a Common Lisp adaptation of XOM, so the design was clear<br>from the start.<br><br>> Finally, does anyone know why I need to pass the function the first<br>> child? Seem cxml-stp is getting tripped up on the first line of
the<br>> xml file: <?xml version="1.0" encoding="UTF-8"?> and forcing me to<br>> manually grab the second element. Is there a convention or idiom I'm<br>> missing?<br><br>I see no reason why you would have to call stp:first-child. The example<br>works without that call.<br><br><br>d.<br><br><br><br> </div> </div> </div></body></html>