RE: Retrieving parts of a document

The XPath type system does not have "tree" as a type of object, so an
XPath expression cannot retrieve a tree as such. Instead, when you are
interested in getting a tree, you select the node that is the root of
that tree. It's then up to the application to access the subtree below
this node in whatever way it wants, either using XPath navigation or
using the native data model accessors.
 
Michael Kay

-----Original Message-----
From: www-xpath-comments-request@w3.org
[mailto:www-xpath-comments-request@w3.org] On Behalf Of Kirmse, Daniel
Sent: 21 January 2004 09:02
To: www-xpath-comments@w3.org
Subject: Retrieving parts of a document



Hi,

is there a way to retrieve a part of a document as XML?

Suppose this document:

<?xml version="1.0"?>

<!DOCTYPE chapter PUBLIC "-//X-HIVE/Generated Public ID 101//EN"
"dtd/books.dtd">

<chapter>

  <title>Data Model</title>

  <section>

    <title>Syntax For Data Model</title>

  </section>

  <section>

    <title>XML</title>

    <section>

      <title>Basic Syntax</title>

    </section>

    <section>

      <title>XML and Semistructured Data</title>

    </section>

  </section>

</chapter>

The result I have in mind is:

  <section>

    <title>XML</title>

    <section>

      <title>Basic Syntax</title>

    </section>

    <section>

      <title>XML and Semistructured Data</title>

    </section>

  </section>


By using a XPath expression like /chapter/section[child::title/text() =
"XML"] I would merely navigate to the context of node "section" (Well
maybe the phrasing is not right. I hope I made you understand my
intention).

Do I have to use XQuery to accomplish that? Well I think I could write a
XQuery expression for that example that generates the output. But what
if I do not know the structure of the subtree/part of document to
retrieve but only the structure of the root node of this subtree/part of
document?


Thanks,

Daniel

Received on Wednesday, 21 January 2004 10:35:34 UTC