This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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"?>
<ni:page xmlns:ni="http://ni.com.au/newspublish">
<ni:container name="main">
<ni:story ni:id="367">
<ni:body>The quick brown fox jumped over the lazy brown dog.</ni:body>
<ni:byline>by me</ni:byline>
<ni:headline>Making progress</ni:headline>
</ni:story>
<ni:story ni:id="368">
<ni:body>This is the body of the second story</ni:body>
<ni:byline>by dim</ni:byline>
<ni:headline>Making more progress</ni:headline>
</ni:story>
<ni:story ni:id="369">
<ni:body>This is the body of the third story</ni:body>
<ni:byline>by dim</ni:byline>
<ni:headline>Making more progress still</ni:headline>
</ni:story>
<ni:story ni:id="400">
<ni:headline>Drop in skilled vacancies</ni:headline>
<publication-time>9:50 am (AEST)</publication-time>
<ni:byline>From AAP</ni:byline>
<ni:body>
<p>9.50am (AEDT) AUSTRALIAN <em>skilled</em> vacancies fell by 4.7 per cent in October on the back of a drop in the call for construction-related occupations, The Department of Employment, Workplace Relations and Small Business said today.</p>

<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>The strongest falls were for construction trades, 26.3 per cent, wood and textile trades, 16.9 per cent, and printing trades, 13 per cent. </p>

<p>Skilled vacancies remained steady for professionals during October. </p>
<p>Marketing and advertising professionals' skilled vacancies rose 6.3 per cent, accountants and auditors rose 4.6 per cent, science professionals increased 4.2 per cent and social worker skilled vacancies were up 2.8 per cent. </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>
<p>DEWRSB said computer professionals had been removed from the skilled vacancies index because of the shift of advertising to the Internet.</p>

</ni:body>
</ni:story>
</ni:container>
<ni:container name="navbar">
<link />
</ni:container>
</ni:page>

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">
<xsl:copy-of select="node()" />
</xsl:template>

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,
Mike


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]