File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Help with XSL element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Help with XSL element" Watch "Help with XSL element" New topic
Author

Help with XSL element

Andrew Cane
Ranch Hand

Joined: Aug 07, 2013
Posts: 91
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

Joined: Jan 18, 2011
Posts: 464
    
    2
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

Joined: Aug 07, 2013
Posts: 91
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

Joined: Jan 18, 2011
Posts: 464
    
    2
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

Joined: Aug 07, 2013
Posts: 91
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

Joined: Aug 07, 2013
Posts: 91
okay, now I think I understand why this happens. thanks for the response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with XSL element
 
Similar Threads
what is template rule in xsl ?
xsl processing
why is the output not displayed
Using XSL to display XML
Namepace problem with Xalan/XSLT