Re: Editing XML
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jun 2007 21:35:46 +0200
"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
.
- Follow-Ups:
- Re: Editing XML
- From: Hans-Peter Diettrich
- Re: Editing XML
- References:
- Editing XML
- From: Hans-Peter Diettrich
- Re: Editing XML
- From: Rob Kennedy
- Re: Editing XML
- From: Hans-Peter Diettrich
- Re: Editing XML
- From: Rob Kennedy
- Re: Editing XML
- From: Rob Kennedy
- Re: Editing XML
- From: Hans-Peter Diettrich
- Re: Editing XML
- From: Maarten Wiltink
- Re: Editing XML
- From: Hans-Peter Diettrich
- Editing XML
- Prev by Date: Re: Set the CheckBox.Checked without the OnClick being called
- Next by Date: Re: Set the CheckBox.Checked without the OnClick being called
- Previous by thread: Re: Editing XML
- Next by thread: Re: Editing XML
- Index(es):
Relevant Pages
|