I have these XML files:
master.xml (which uses XInclude to include child1.xml and child2.xml)
child1.xml
child2.xml
Both child1.xml
and child2.xml
contain a <section>
element with some text.
In the XSLT transformation, I 'd want to add the name of the file the <section>
element came from, so I get something like:
<section srcFile="child1.xml">Text from child 1.</section>
<section srcFile="child2.xml">Text from child 2.</section>
How do I retrieve the values child1.xml
and child2.xml
?
Unless you turn off that feature, all XInclude processors should add an @xml:base attribute with the URL of the included file. So you don't have to do anything, it should already be:
<section xml:base="child1.xml">Text from child 1.</section>
<section xml:base="child2.xml">Text from child 2.</section>
( If you want, you can use XSLT to transform the @xml:base attr into @srcFile. )