• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

xslt troubles ...

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i've got an xml file like this

---------------------
and i'd like to make an fo that displays
the courseName for each course and then the title (and content) of the chapters of THIS course.
something like :
WEB
HTTP
contentHTTP
HTML
contentHTML
JAVA
Observer Design Pattern
contentODP
...
the way i do it now :

-----------------------------------
it doesn't work because for each course, it displays ALL the chapters.
could you give me some help .. thanks
oLi
[ July 25, 2002: Message edited by: oLi Bou ]
[ July 25, 2002: Message edited by: oLi Bou ]
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looks like the problem is here:
<xsl:for-each select="//chapter"> - it will select all elements named chapter in the document, regardless of context. You need to change it to
<xsl:for-each select="chapter">
- then only chapters that are children of the current node will be selected.
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this!!..

Next time please post ur code using UBB code with indention so that it will be easier to read.
Who said " XML is both human readable and machine readable" is that Sun microsystems??
 
oLi Bou
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why, Why, Why didn't I found it by myself ?
i changed the post with the UBBcode thanks for the advice ...
and thanks for the trick too
oLi
[ July 25, 2002: Message edited by: oLi Bou ]
 
oLi Bou
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I've got two other questions about this piece of code ..
1) how could it be possible to render the title differently if it is a level1 title or a level2, or level3, ...
2) with your code, my chapter titles aren't displayed correctly because i can have chapters inside chapters. and with the ./chapter, it can only take the "first level" chapters, and not the others. I tried something like this ".//chapter" but it doesn't go, because of my <xsl:apply-templates/> tag. it displays all the chapters twice.
I know it is possible because i read it somewhere but I can't find it anymore
thx
[ July 25, 2002: Message edited by: oLi Bou ]
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by oLi Bou:
1) how could it be possible to render the title differently if it is a level1 title or a level2, or level3, ...


Sorry! I can't understand ur question.


2) with your code, my chapter titles aren't displayed correctly because i can have chapters ...



3st line select the root
4nd line selects the course one by one
6th line prints course name
7th line selects the chapter inside the each course one by one
...
...
Regards
Balaji
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic