This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Q: How to manipulate XML based on attribute?


I've got the following XML file:
=============
<Page>
  <Person>
    <Name vip="true">John Smith</Name>
    <Friend>Joe Blow</Friend>
  </Person>
</Page>
=============

The vip attribute could occur on any element (this is a simplified structure
just for example purposes, so assume there could be many different elements
besides just these).  In other words, it could occur on the Person element,
or the Friend element, or not at all.

Wherever the vip attribute appears, I want to embed the result of whatever I
do with that element in <em></em> tags in the resultant HTML.  For the
example given above, I'd want the resultant HTML to look like the following:

<html>
  <body>
    <em><h1>John Smith</h1></em>
    Joe Blow
  </body>
</html>

So, obviously in the standard XSL, I'm embedding the Name element in a <h1>
tag.  However, since it specifies the vip attribute, I need to embed the
resultant manipulation of that tag in an <em> element.  Since I don't know
which element the attribute may appear on, I need a generic way to handle
it.

Is this possible?  What would the XSL need to look like to do this kind of
manipulation (especially where I don't know on which element the attribute
could occur)?

Thanks for your help!

- Sean T.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]