• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with XSL element

 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the source document:



and this is the stylesheet:


1. what really confuses me is the apply-templaets code. what does it do? I googled and got an example to exclude certain element, but still not clear. what does that mean? doesn't the processor ignore document's elements that doesn't match select criteria?
2. the template match="title" part is also confusing. the first template match="/" already output the title, so why do the same thing twice? the second "template match="title"" doesn't put <h1> tag anyway.
thanks
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. what really confuses me is the apply-templaets code. what does it do? I googled and got an example to exclude certain element, but still not clear. what does that mean? doesn't the processor ignore document's elements that doesn't match select criteria?

This is described in the section 5.4 applying template rules of the recommendation.
http://www.w3.org/TR/xslt#section-Applying-Template-Rules

2. the template match="title" part is also confusing. the first template match="/" already output the title, so why do the same thing twice? the second "template match="title"" doesn't put <h1> tag anyway.

Output the title or output the title tag's text via an xpath expression is one thing, a template intended to match title tag, which is sitting there awaiting its big time, is another. They are two separate concepts. Since xpath is by-design capable of reaching anywhere from anywhere in the document, an output of title's text value can theoretically appear anywhere as you like it.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about this


from this source


why is Mr. Bean still displayed when we have specifically instructed the processor to process only student element?
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are saying your new case invalidate my previous response? In that case, may be you've to figure it out then as my previous effort does not help.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't mean anything. I just don't understand about this phenomenon, that's why I joined this forum in the first place, because I got stuck learning on my own. so I hope those who already have knowledge about this subject would be kind enough to share their knowledge. thanks
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, now I think I understand why this happens. thanks for the response.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic