W3C home > Mailing lists > Public > www-xpath-comments@w3.org > January to March 2004

Retrieving parts of a document

From: Kirmse, Daniel <daniel.kirmse@sap.com>
Date: Wed, 21 Jan 2004 10:01:59 +0100
Message-ID: <22772E6015DA354B84C6F8DB8BF60504D0ECD1@dewdfx13.wdf.sap.corp>
To: www-xpath-comments@w3.org
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 04:03:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:05:55 GMT