No-fail `document` Function Spec

"John L. Clark" <[email protected]>
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <20060224002154.GW10347@rejoice>
While the environment variables namespace proposal is still pending, I
thought I might start work on the next item on the EXSLT TODO list.  For
me, this is the Resource module, and I decided to start with the no-fail
document function.  I should have attached the source XML and the user
HTML view for this function to this email.  I can also send the use-case
sources and the module file, if people want to hack on those as well at
this time.

I look forward to your feedback.

Take care,

    John L. Clark

_______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list
res.document.xml (text/plain, 4.3 KB)
<?xml version="1.0"?>
<exslt:function xmlns:exslt="http://exslt.org/documentation" 
                version="1" module="res" status="new">

<exslt:name>document</exslt:name>

<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 ID="res:document">
  <dc:subject>EXSLT</dc:subject>
  <dc:subject>res</dc:subject>
  <dc:subject>document</dc:subject>
  <dc:rights>public domain</dc:rights>
  <exslt:revision>
    <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                     xmlns:dc="http://purl.org/dc/elements/1.1/"
                     ID="res:document.1">
      <exslt:version>1</exslt:version>
      <dc:creator email="[email protected]" 
                 url="http://infinitesque.net/">John L. Clark</dc:creator>
      <dc:date>2006-02-22</dc:date>
      <dc:description>Fetches status-encapsulated documents by URI.</dc:description>
    </rdf:Description>
  </exslt:revision>
</rdf:Description>

<exslt:doc xmlns="http://www.w3.org/1999/xhtml">
  <p>The <code>res:document</code> function has the same behavior as the <a
  href="http://www.w3.org/TR/xslt#document"><code>document</code></a>
  function with the following significant differences.  For the following
  description, the <code>rslt</code> namespace prefix maps to the
  <code>http://exslt.org/resource/result</code> URI.</p>

  <p>When the first argument to the <code>res:document</code> function is
  not a node-set, this function performs the same processing as the
  <code>document</code> function, but instead of returning the constructed
  node-set, it returns a result node-set that is defined as follows.  If the
  constructed node-set contains only a document node, then define the
  encapsulated node-set to be the set of all child nodes of this document
  node.  Otherwise, the encapsulated node-set is the constructed node-set.
  The result node-set, which is returned from this function, consists of a
  <code>rslt:success</code> element with the encapsulated node-set as its
  children.  This element SHOULD also have a <code>uri</code> attribute that
  contains the absolute URI that this function retrieved.  If there is an
  error retrieving the resource, then this function returns the node-set
  containing the root of a tree of the following form:</p>

  <pre><![CDATA[<rslt:error xmlns:rslt="http://exslt.org/resource/result"
            uri="http://www.example.org/">
  <rslt:failed>
    <rslt:category>protocol</rslt:category>
    <rslt:item>http</rslt:item>
  </rslt:failed>
  <rslt:code>404</rslt:code>
  <rslt:message>Not Found</rslt:message>
</rslt:error>]]></pre>

  <p>The elements contained in this error descriptor are mandatory unless
  stated otherwise.  In such an error descriptor, the <code>uri</code>
  attribute should contain the absolute URI that triggered the error.  The
  <code>rslt:failed</code> element MUST contain an
  <code>rslt:category</code> element and MAY contain an
  <code>rslt:item</code> element.  The <code>rslt:category</code> element
  indicates the area of failure.  Its value SHOULD be one of "scheme",
  "connection", "protocol", or "XML" to indicate an unsupported scheme,
  problems in the network, problems with a particular document exchange
  protocol, or problems in the resulting document, respectively, or some
  other application-specific value to indicate a different type of problem.
  If the value of the <code>rslt:category</code> element is "protocol", then
  the <code>rslt:item</code> element SHOULD contain the name of the protocol
  (as listed in <a href="http://www.iana.org/assignments/port-numbers">the
  TCP and UDP Port Numbers list</a>) that failed.  The
  <code>rslt:code</code> element is optional, and SHOULD contain the error
  code corresponding to the error, if such a code exists.
  <code>rslt:message</code> is also optional, and contains any error message
  that was provided by the source of the error.</p>
</exslt:doc>

<exslt:definition>
  <exslt:return type="node-set" />
  <exslt:arg name="object" type="object" optional="no" />
  <exslt:arg name="node-set" type="node-set" default="/.." />
</exslt:definition>

<exslt:use-cases>
  <exslt:use-case type="example" data="use-cases/1/data.xml" 
                 xslt="use-cases/1/script.xsl" 
                 result="use-cases/1/result.xml"/>
</exslt:use-cases>

</exslt:function>
index.html (text/html, 6.4 KB)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/schema/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>EXSLT - res:document</title><link href="http://exslt.org/base.css" rel="stylesheet"/></head><body><h1 id="#title"><a href="http://www.exslt.org/">EXSLT</a> - <a href="http://www.exslt.org/res">res</a>:<a href="http://www.exslt.org/res/functions/document">document</a></h1><table><tr><td id="menu"><p class="level1"><a href="res.document.html">Implementer Page</a></p><p class="level1"><a href="../../../howto.html">How To</a></p><p class="level1"><a href="../../../download.html">Downloads</a></p><p class="level1">Modules</p><p class="level2"><a href="../../../date/index.html">Dates and Times</a></p><p class="level2"><a href="../../../dyn/index.html">Dynamic</a></p><p class="level2"><a href="../../../exsl/index.html">Common</a></p><p class="level2"><a href="../../../func/index.html">Functions</a></p><p class="level2"><a href="../../../math/index.html">Math</a></p><p class="level2"><a href="../../../random/index.html">Random</a></p><p class="level2"><a href="../../../regexp/index.html">Regular Expressions</a></p><p class="level2"><a href="../../../res/index.html">Resource</a></p><p class="level3"><a href="../../functions/document/index.html">res:document()</a></p><p class="level2"><a href="../../../set/index.html">Sets</a></p><p class="level2"><a href="../../../str/index.html">Strings</a></p><p class="level2"><a href="../../../sys/index.html">System</a></p><p class="level1"><a href="../../../submissions/">Submissions</a></p><p class="level1"><a href="../../../list">Mailing List</a></p><p class="level1"><a href="../../../contact.html">Contact</a></p></td><td id="content"><p><b>Implementer Page: </b><a href="res.document.html">res.document.html</a><br/><b>Function Package: </b><a href="res.document.zip">res.document.zip</a></p><h4>Function Syntax</h4><pre><var>node-set</var> <b>res:document</b>(<var>object</var>, <var>node-set</var>)</pre><p>The <code>res:document</code> function has the same behavior as the <a href="http://www.w3.org/TR/xslt#document"><code>document</code></a>
  function with the following significant differences.  For the following
  description, the <code>rslt</code> namespace prefix maps to the
  <code>http://exslt.org/resource/result</code> URI.</p><p>When the first argument to the <code>res:document</code> function is
  not a node-set, this function performs the same processing as the
  <code>document</code> function, but instead of returning the constructed
  node-set, it returns a result node-set that is defined as follows.  If the
  constructed node-set contains only a document node, then define the
  encapsulated node-set to be the set of all child nodes of this document
  node.  Otherwise, the encapsulated node-set is the constructed node-set.
  The result node-set, which is returned from this function, consists of a
  <code>rslt:success</code> element with the encapsulated node-set as its
  children.  This element SHOULD also have a <code>uri</code> attribute that
  contains the absolute URI that this function retrieved.  If there is an
  error retrieving the resource, then this function returns the node-set
  containing the root of a tree of the following form:</p><pre>&lt;rslt:error xmlns:rslt="http://exslt.org/resource/result"
            uri="http://www.example.org/"&gt;
  &lt;rslt:failed&gt;
    &lt;rslt:category&gt;protocol&lt;/rslt:category&gt;
    &lt;rslt:item&gt;http&lt;/rslt:item&gt;
  &lt;/rslt:failed&gt;
  &lt;rslt:code&gt;404&lt;/rslt:code&gt;
  &lt;rslt:message&gt;Not Found&lt;/rslt:message&gt;
&lt;/rslt:error&gt;</pre><p>The elements contained in this error descriptor are mandatory unless
  stated otherwise.  In such an error descriptor, the <code>uri</code>
  attribute should contain the absolute URI that triggered the error.  The
  <code>rslt:failed</code> element MUST contain an
  <code>rslt:category</code> element and MAY contain an
  <code>rslt:item</code> element.  The <code>rslt:category</code> element
  indicates the area of failure.  Its value SHOULD be one of "scheme",
  "connection", "protocol", or "XML" to indicate an unsupported scheme,
  problems in the network, problems with a particular document exchange
  protocol, or problems in the resulting document, respectively, or some
  other application-specific value to indicate a different type of problem.
  If the value of the <code>rslt:category</code> element is "protocol", then
  the <code>rslt:item</code> element SHOULD contain the name of the protocol
  (as listed in <a href="http://www.iana.org/assignments/port-numbers">the
  TCP and UDP Port Numbers list</a>) that failed.  The
  <code>rslt:code</code> element is optional, and SHOULD contain the error
  code corresponding to the error, if such a code exists.
  <code>rslt:message</code> is also optional, and contains any error message
  that was provided by the source of the error.</p><h2>Examples</h2><h3>Function</h3><p>The following example shows how to use the <code>res:document</code> function:</p><h4>Source</h4><pre>&lt;doc&gt;
   &lt;result-from uri="http://www.example.org/" /&gt;
   &lt;result-from uri="data.xml" /&gt;
   &lt;p&gt;Note that "data.xml" refers to this document.&lt;/p&gt;
&lt;/doc&gt;</pre><h4>Stylesheet</h4><pre>&lt;xsl:template match="/doc"&gt;
   &lt;output&gt;
      &lt;xsl:copy-of select="res:document(result-from[1]/@uri)" /&gt;
      &lt;xsl:copy-of select="res:document(result-from[2]/@uri)" /&gt;
   &lt;/output&gt;
&lt;/xsl:template&gt;</pre><h4>Result</h4><pre>&lt;output xmlns:rslt="http://exslt.org/resource/result"&gt;
   &lt;rslt:error uri="http://www.example.org/"&gt;
      &lt;rslt:uri&gt;http://www.example.org/&lt;/rslt:uri&gt;
      &lt;rslt:failed&gt;
         &lt;rslt:category&gt;connection&lt;/rslt:category&gt;
      &lt;/rslt:failed&gt;
      &lt;rslt:message&gt;Connection refused&lt;/rslt:message&gt;
   &lt;/rslt:error&gt;
   &lt;rslt:success uri="file:///some/path/to/data.xml"&gt;
      &lt;doc&gt;
         &lt;result-from uri="http://www.example.org/" /&gt;
         &lt;result-from uri="data.xml" /&gt;
         &lt;p&gt;Note that "data.xml" refers to this document.&lt;/p&gt;
      &lt;/doc&gt;
   &lt;/rslt:success&gt;
&lt;/output&gt;</pre></td></tr></table><div id="colophon"><p><a href="http://www.exslt.org/res/functions/document/index.html">http://www.exslt.org/res/functions/document/index.html</a> last modified 2006-02-22</p></div></body></html>
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFD/lGijkcskvOyl78RAvV4AJ459l1wKNIIQmQdFmSXp3nvHnqLwQCfftog
CRBuMnLx6jCNPRJUknCpa5o=
=NCrZ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.