Re: Editing XML



"Hans-Peter Diettrich" <DrDiettrich1@xxxxxxx> wrote in message
news:5d5jtuF33j3raU1@xxxxxxxxxxxxxxxxxxxxx
Maarten Wiltink wrote:

<xsl:apply-templates select="*|text()" /> <!-- exclude @* -->

Does here "@" refer to (all?) attributes, "*" to all childnodes, and
text() to the text? The members of the elements (or nodes?) still are
somewhat unclear to me :-(

* is short for all nested elements, @* for all nested attributes,
text() for all nested text nodes, node() for all nested nodes. A
few other node types such as processing instructions and comments
are dutifully ignored in the above code.

You may want to read the XSLT and XPath specs from W3C. It's a long
read, but well worth it - at least I thought so. Be warned that I
also thought Christopher Tolkien's editions of his father's mislaid
writing worth it. There is a certain similarity; both are not to
everyone's taste.


Also I didn't understand the difference between XMLDoc.DocumentElement,
.Node and .ChildNodes. Is .Node the very root node of the document,
whose children are the .ChildNodes, and .DocumentElement is one of these
children? There also seems to exist a flat list of all elements or nodes
in a document?

No, .DocumentElement is the document's root node. .Node is probably
a more volatile 'current node' thing, more useful from other node types
than documents.

The discussion is muddied by several things running together. The XML
DOM specification defines an API for creating and tearing apart XML
documents, but functions that select nodesets take query strings that
are defined by the separate XPath spec. XLST also defers to XPath in
similar points, like select attributes in several places.

And XPath displays little unity of form, at least in its shortcuts,
of which there are many. And all the function syntax doesn't help,
either.

'attribute::key' is what XPath should look like (attribute axis, so
all attributes in the current node, which should be an element for
there to be any attributes; name then must match 'key'). '@key' is
a shortcut for same. 95% of your XPath needs can usually be filled
by shortcuts, making the other 5% hard to master.

And many functions (text(), node(), and others) are placed in XPath
for grammatical convenience, but XPath is not about functions. It is
about matching, and powerful matching needs the functions.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: Random access of XML file
    ... select all nodes matching an XPath expression. ... selects the first node that matches the XPath ... Fundamentally, if it's not well-formed XML, then it isn't XML, period. ... look at XSLT, but that may be overkill depending on your needs. ...
    (microsoft.public.dotnet.xml)
  • ANN: XMLMax Virtual XML Editor Beta
    ... Xponent is pleased to announce Beta version 2.0.5 of its XMLMax ... Virtual XML Editor. ... It provides xpath query and editing of any xml file, ...
    (microsoft.public.dotnet.framework)
  • ANN: XMLMax Virtual XML Editor Beta
    ... Xponent is pleased to announce Beta version 2.0.5 of its XMLMax ... Virtual XML Editor. ... It provides xpath query and editing of any xml file, ...
    (microsoft.public.office.misc)
  • ANN: XMLMax Virtual XML Editor Beta
    ... Xponent is pleased to announce Beta version 2.0.5 of its XMLMax ... Virtual XML Editor. ... It provides xpath query and editing of any xml file, ...
    (microsoft.public.biztalk.general)
  • ANN: XMLMax Virtual XML Editor Beta
    ... Xponent is pleased to announce Beta version 2.0.5 of its XMLMax ... Virtual XML Editor. ... It provides xpath query and editing of any xml file, ...
    (comp.text.xml)