applying templates based on attribute values
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Borsz
Posted On:   Thursday, August 11, 2005 11:45 AM

I work in XSL with very large document-oriented XML structures, so it's usually difficult to show clear examples of the problems I run into. My trouble right now is applying templates of a node, based on it's attribute value. In my document, I'll have something like 'exampleElementA', with an attribute 'exampleAttributeA'. When I process 'exampleElementA', I want to apply the templates of an element (which I usually will not know the name of, and never know the position of) that occurs much further in the document, which almost always has a different element name and different attribute name, but the same attribute value. Is there a way to group elements solely on attribute values, regardless of element and attribute names? Is grouping (which I'm not so hot at    More>>

I work in XSL with very large document-oriented XML structures, so it's usually difficult to show clear examples of the problems I run into.

My trouble right now is applying templates of a node, based on it's attribute value. In my document, I'll have something like 'exampleElementA', with an attribute 'exampleAttributeA'. When I process 'exampleElementA', I want to apply the templates of an element (which I usually will not know the name of, and never know the position of) that occurs much further in the document, which almost always has a different element name and different attribute name, but the same attribute value.

Is there a way to group elements solely on attribute values, regardless of element and attribute names? Is grouping (which I'm not so hot at yet) even the method I want to use, or is this just a Xpath problem? Thanks for your help, and I'd be glad to expand on anything if needed. Have a good day.

   <<Less

Re: applying templates based on attribute values

Posted By:   Anonymous  
Posted On:   Friday, August 12, 2005 01:39 PM

you could start with something like that:




BUT:


a) Be sure the node you just called processing for will not be processed again later on - I don't know whether this would happen in your structure. If that node falls into the same template, you could get into an infinite loop!



b) As you are working on large documents: Everything including "//" is performing rather poorly.


Good luck!

sonja
About | Sitemap | Contact