<html><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:8pt"><div><span>Hi Ray,</span></div><div><span><br></span></div><div><span>Thanks. It does seems easier with xpath. Perhaps it's my stubbornness that keeps me hammering away at cxml-stp. If no one comes up with a good example for STP, I think I'll take the path of least resistance and do as you suggest.</span></div><div><span><br></span></div><div><span>Cheers,</span></div><div><span><span class="Apple-tab-span" style="white-space:pre">  </span>- Steve</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> Raymond Wiker <rwiker@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b>
 Steven Nunez <steve_nunez@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "cxml-devel@common-lisp.net" <cxml-devel@common-lisp.net> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, June 11, 2012 5:14 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [cxml-devel] Real-world example: with attachment<br> </font> </div> <br>
<div id="yiv1401922647"><div><div><div>On Jun 11, 2012, at 05:50 , Steven Nunez wrote:</div><blockquote type="cite"><span class="yiv1401922647Apple-style-span" style="border-collapse: separate; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium; font-family: Helvetica; "><span class="yiv1401922647Apple-style-span" style="font-size: 11px; font-family: verdana, helvetica, sans-serif; "><div style="display:block;">(defun algorithm-name (model)</div><div style="display:block;">  "Returns the algorithm for the model"</div><div style="display:block;">  (stp:filter-recursively (stp:of-name "algorithmName" (stp:namespace-uri model)) model))</div></span></span><br class="yiv1401922647Apple-interchange-newline"></blockquote></div><br><div>I'd do something like the
 following:</div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><div>(defun algorithm-name (model)</div><div>  (xpath:with-namespaces ((nil "http://www.dmg.org/PMML-4_0"))</div><div>    (xpath:string-value (xpath:evaluate "//RegressionModel/@algorithmName" model))))</div><div><br></div><div>(defun model-coefficient-list (model)</div><div>  (xpath:with-namespaces ((nil "<a rel="nofollow" target="_blank" href="http://www.dmg.org/PMML-4_0">http://www.dmg.org/PMML-4_0</a>"))</div><div>    (let ((regression-model-node (xpath:first-node (xpath:evaluate "//RegressionModel" model)))</div><div>          (*read-eval* nil))</div><div>      `(,(xpath:string-value (xpath:evaluate "@modelName" regression-model-node))</div><div>        ,@(xpath:map-node-set->list</div><div>           (lambda (node)</div><div>     
        (list</div><div>              (xpath:string-value (xpath:evaluate "@name" node))</div><div>              ;; note: xpath:number-value may work here, depending on</div><div>              ;; your implementation... does not work with Lispworks</div><div>              ;; 6.1 under Mac OS X</div><div>              (read-from-string (xpath:string-value (xpath:evaluate "@coefficient" node)))))</div><div>           (xpath:evaluate "RegressionTable/NumericPredictor" regression-model-node))))))</div><div><br></div><div>#||</div><div>(defparameter *model*</div><div>  (cxml:parse #p"/Users/raw/Desktop/polynomial-regression.xml" (cxml-stp:make-builder)))</div><div><br></div><div>(cxml-stp:serialize *model* (cxml:make-string-sink
 :indentation 4))</div><div><br></div><div>(algorithm-name *model*)</div><div><br></div><div>(model-coefficient-list *model*)</div><div>||#</div></div><div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br></div><div><br></div><div>Notes:</div><div><br></div><div>1) I'm not sure that model-coefficient-list does what you need.</div><div><br></div><div>2) It might be appropriate to use cxml-stp:attribute-value instead of xpath:string-value/xpath:evaluate.</div><div><br></div><div>3) Since there are multiple coefficients with the same name (where some have an "exponent" attribute), I guess you'd either need to filter out some of the coefficients, build names that somehow incorporate the exponent, or add the exponent to the list structure returned.</div><div><br></div><div>Hope this helps.</div></div></div></div><br><br> </div> </div>  </div></body></html>