The capture logicsheet allows you to get parts of your XML as an XMLFragment object or as a DOM node, apparently.

I think this might be useful for post-processing SOAP calls from XSP! There is a very brief reference to capture in the "Cocoon developers handbook", but not much.

See api docs

Code Sample

<capture:dom-variable name="blahDom">
  <blah>you are the one, mr blah</blah>
</capture:dom-variable>
...
<xsp:expr>blahDom</xsp:expr>

Will insert <blah>you are the one, mr blah</blah> into your xml

XSPCature and SOAP

note, unfinished As an example, you might want to deal with your returned SOAP data. This technique allows us to inspect the returned SOAP result and extract data from it. This technique uses inline xslt, which is interesting in itself. Note the inspiration from this came from the getquote2.xsp in /samples/soap/pages/xscript.

<xscript:variable name="soap-result">
  <soap:call url="http://www.somesoapurl.com.net.omg.whee"
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/1999/XMLSchema">
     <ns1:login xmlns:ns1="http://www.soapware.org/">
      <username xsi:type="xsd:string">someusername</username>
      <password xsi:type="xsd:string">somepassword</password>
     </ns1:login>
   </soap:call>
</xscript:variable>

<xscript:variable name="stylesheet">
   <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:ns1="http://www.soapware.org/"
                  exclude-result-prefixes="SOAP-ENV ns1">
    <xsl:template match="/">
    	<para>
        <xsl:value-of select="/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:loginResponse/sessionid"/>
        </para>
        <!-- <xsl:value-of select="/SOAP-ENV:Envelope"/> -->
    </xsl:template>
  </xsl:stylesheet>
</xscript:variable>

<capture:dom-variable name="testDomFragment">
  <xscript:transform name="soap-result" stylesheet="stylesheet"/>
</capture:dom-variable>
  • No labels