|Question about XSL stylesheet|
| 2:06 pm on Apr 1, 2010 (gmt 0)|
I'm trying to develop a generic stylesheet that will work with any XML document, regardless of the names of its nodes, but I'm not sure how to reference them .
For example, using the example from the W3C schools website,
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<h2>My CD Collection</h2>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
This style sheet specifies specific node names such as 'catalog', 'cd','title', 'artist, etc. What would you do if you just wanted it to output the nodes generically without the need to specify a name, so that the style sheet would work with all xml documents of the same format?
I tried using 'root' and 'firstChild', etc but it didn't seem to work, any ideas?
| 6:22 am on Apr 3, 2010 (gmt 0)|
you'll need to sharpen your Axes [w3.org]
| 7:46 am on Apr 7, 2010 (gmt 0)|
I am interested to know what this Axes is about. I have been using a lot of HTML and XSL,but had not really thought about this.
| 11:53 am on Apr 7, 2010 (gmt 0)|
Axes are plural of "axis" - a strange usage of the word, but it's the name of a device that lets an XPATH expression refer to a parent, ancestor, sibling, descendent-or-self, etc.
An axis is a selector that can find a node based on its relationship to the current node, regardless of its name or type. You can get the first child of a <book>, without knowing that it's a <chapter>.
Knowing XPATH is useful in all finds of XML parsing situations, not just in XSLT templates. If you are familiar with CSS selectors, XPATH has a lot in common with those.