template matching using namespace
Once again your help with my 2 questions will be highly appreciated.
First, I have a template in which I only use the namespace to filter out the elements. But based on the content I want to behave in different ways inside the template. So, let's say I have the snippet below
<constraint:SimpleConstraint rdf:ID="ph_student"> <constraint:subject rdf:resource="#var1"/> <constraint:predicate rdf:resource="&rdf;type"/> <constraint:object rdf:resource="&univ;PhD"/> <policy:desc>PhD student</policy:desc> </constraint:SimpleConstraint>
<constraint:And rdf:ID="andedConstraints"> <constraint:firstt rdf:resource="#isPhdStudent"/> <constraint:second rdf:resource="#isLivingInOurLab"/> </constraint:SimpleConstraint>
<constraint:SimpleConstraint rdf:ID="oredConstraints"> <constraint:firstt rdf:resource="#wasPhDStudent"/> <constraint:second rdf:resource="#wasWorkingInOurLab"/> </constraint:SimpleConstraint>
and the following template:
<xsl:template match="constraint:*"> <!-- some code --> </xsl:template>
if I apply my template to the XML file above then it will catch all the three elements. is there any way I can find out which one is currently being caught by the current template that the program counter is in?
I know I could have 3 different templates defined, with the element names explicitly written, but then I have to have redundant code that I prefer to avoid.
thanks a lot, -Nima
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format