|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] child and descendant: what is the difference really
Title: child and descendant: what is the difference really
Ok this question concerns the differance between the child and descendant axes. Accordoing to Mike Kay's book child is just the elements immediately enlosed by the context element, while the descendant axis is recursive and contains not only the child elements, but their children and their children's children etc. If this is the case then the following totally confuses me. Here is the input xml note that it is just a set of test stories, with all but the last story having text directly between the parent <ni:body> tags. The last story has standard HTML look-alike <p> tags with enclosed <em> tags. The last story is a mimic of how a true story would come through, but I have to be prepared for loose, untagged, text as well. <?xml version="1.0" encoding="UTF-8"?>
<p>Skilled vacancies were 15.9 per cent lower than the same time last year, but DEWRSB said they still remained at a relatively high level. </p> <p>In October, skilled vacancies fell for 14 of the 18 occupational groups.</p>
<p>Skilled vacancies remained steady for professionals during October. </p>
<p>All states and the Northern Territory recorded a fall in skilled vacancies except for Tasmania, which had a 0.9 per cent rise. </p> <p>The strongest annual increases in skilled vacancies were in science professionals, 27.8 per cent, and accountants and auditors, 12.9 per cent. </p> <p>Over the year to October, skilled vacancies for trades fell by 29 per cent. </p>
</ni:body>
Essentially, all I want is for everything between the <ni:body> tags to be copied to the output HTML. I have solved this with the following: <xsl:template match="ni:body">
but I don't understand my answer as I would have expected: <xsl:copy-of select="text() | descendant::node()" /> working. That is, "I want all the text of the current (ni:body) node plus all of the descendants of this node". This did not work. The fact that: <xsl:copy-of select="node()" /> did work confuses me, since I know that it is shorthand for child::node(), which should, according to Mike Kay's book, reach down to only the <p> elements in the source tree, and not down to the <em> tags within (these are not children of <ni:body> as I understood it). There is obviously something significant I'm not getting here, I'd really appreciate someone telling me what that hole in my understanding is. regards,
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








