Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > print all subelements plus content

Reply
Thread Tools

print all subelements plus content

 
 
David Simons
Guest
Posts: n/a
 
      02-23-2005
Hi,

I don't know how to print out all subcontent of an
element with xslt. E.g.
<book>
<chapter>first chapter
<content>
lorem ipsum bla
</content>
</chapter>
<chapter>second chapter
<content>
that and this and this and that
</content>
</chapter>
.......
</book>

xslt:
.....
<xsl:for-each select="book"> <xsl:value-of select="child::*"/>
</xsl:for-each>
....

But this just gives me the first chapter but none of
the other chapters, I don't know why?

Regards,

David

 
Reply With Quote
 
 
 
 
Warrell Harries
Guest
Posts: n/a
 
      02-24-2005
Hi David,

I'm guessing that you are new to XSL. To get the most out of it
requires a change of mind-set and, in my opinion, this requires
avoiding use of <xsl:for-each> until you get your head around the
declarative basis of XSLT.

That aside, to answer your question, what you have done is set the
document context to the first book element and then selected the child
axis only for that first book element.

You would be better off defining a template :-

<xsl:template match="chapter">
<xsl:value-of select="content"/>
</xsl:template>

and then triggering this by using

<xsl:apply-templates select="book"/>

from wherever you want/need to.

I hope this helps - if you persevere it will pay the same sort of
dividends as a true understanding of SQL.

Regards

David Simons <> wrote in message news:<cvj15s$vka$>...
> Hi,
>
> I don't know how to print out all subcontent of an
> element with xslt. E.g.
> <book>
> <chapter>first chapter
> <content>
> lorem ipsum bla
> </content>
> </chapter>
> <chapter>second chapter
> <content>
> that and this and this and that
> </content>
> </chapter>
> ......
> </book>
>
> xslt:
> ....
> <xsl:for-each select="book"> <xsl:value-of select="child::*"/>
> </xsl:for-each>
> ...
>
> But this just gives me the first chapter but none of
> the other chapters, I don't know why?
>
> Regards,
>
> David

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print digital photos online - 9 cents per print, plus 10% off. All sizes from 4x6 up to 30x60. Same price for Matte finish and glossy finish nathan_usny Digital Photography 2 09-12-2005 11:30 PM
Print digital photos online - 9 cents per print, plus 10% off. All sizes from 4x6 up to 30x60. Same price for Matte finish and glossy finish nathan_usny Digital Photography 0 09-12-2005 06:09 PM
SubElements in my WebControl Daniel Jorge ASP .Net 0 07-10-2005 03:57 PM
print all subelements plus content David Simons XML 0 02-23-2005 10:44 PM
Unconnected subelements of Composite Formal Ports Nitin Khurana VHDL 2 04-27-2004 02:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57