I'm trying to create an xslt file so I can find an element which references other elements within an area of my xml file and if that exists I want to replace the reference to the data directly with the data.
So going from:
<school> <People> <teacher Id="1"> <name>Bill</name> </teacher> <teacher Id="2"> <name>Peter</name> </teacher> </People> <Courses> <Course> <name>Maths</name> <teacher Ref="1"/> </Course> <Course> <name>English</name> <teacher Ref="3"/> </Course> <People> <teacher Id="1"> <name>Bill</name> </teacher> <teacher Id="2"> <name>Peter</name> </teacher> <teacher Id="3"> <name>Jill</name> </teacher> </People> </Courses> </school>
to
<school> <People> <teacher Id="1"> <name>Bill</name> </teacher> <teacher Id="2"> <name>Peter</name> </teacher> </People> <Courses> <Course> <name>Maths</name> <teacher Ref="1"/> </Course> <Course> <name>English</name> <teacher Id="3"> <name>Jill</name> </teacher> </Course> <People> <teacher Id="1"> <name>Bill</name> </teacher> <teacher Id="2"> <name>Peter</name> </teacher> <teacher Id="3"> <name>Jill</name> </teacher> </People> </Courses> </school>
So you basically the following course is updated to:
<Course> <name>English</name> <teacher Id="3"> <name>Jill</name> </teacher> </Course>
I'm basically trying to fix data issues with xml but I'm struggling to figure this out using xslt. My example is simplified but the principal is the same.
No comments:
Post a Comment