my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes checking for attribute nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "checking for attribute nodes" Watch "checking for attribute nodes" New topic
Author

checking for attribute nodes

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Hi,
I am trying to convert the attribute text to upper case.
Sample xml -



xsl -

The output xml contains everything from the source xml but the attribute.
What's wrong in the template, matching attribute?

Thanks
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
If you want to structuring xsl like this separating out attribute template, you need to add @* to the apply-templates select because an attribute must be a child of an element. But some detail may be tricker in concept. In the @* template, it is simply non-sense to script apply-templates. An attribute as leaf would have no subnode. A xsl:copy would do it all.

ps:
[1] Do you know what a select or match of node() means? It means *|text() quite literally. So use more consistent form would show you off as having a clearer understanding.
[2] You might one day see @* being integrated into the *|text() in the match attribute. That is the usual concise way to write a so-called identity transformation...
[3] I take out apply-templates within the @* template for the semantic reason, you can put it there and it won't be erroring out of any kind in xslt as it is a kind of functional language. Only that it is "non-sense" in my sense and I mean just that.
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks Tsuji.I got my mistake
 
 
subject: checking for attribute nodes
 
Similar Threads
possible to create dynamically named nodes via xslt?
XSL fails with xmlns
WSAD 5 XML/XSL Validator
xsl namespace and root of xml document
Need help with XSLT, modifying XML config files.