csteinhilber
Programmer
I'm feeling a little stupid at the moment because I'm spinning my wheels trying to figure out what I think should be a pretty simple XSLT concept.
I have one XML file, that I want to combine into another XML file, based on the location of a specific node/element... such that the include XML might look something like:
and then the base XML looks something like:
and when the XSL matches //includeOtherFileHere, I want to do something like:
but all other elements, I simply want to copy verbatim... so the resulting XML would look like:
the problem being... I don't necessarily know the names of the other elements (I may need to match //someOtherChild, or I may need to match //stillSomeOtherChild, or I may need to match some as-yet-unspec'd node name).
What's the most efficient way to perform the value-of of an external document if I match //includeOtherFileHere, otherwise copy the node (and any children) exactly?
It just isn't clicking for me today.
Thanks in advance!
-Carl
I have one XML file, that I want to combine into another XML file, based on the location of a specific node/element... such that the include XML might look something like:
Code:
<?xml version='1.0'?>
<root>
<someElem>
<someChild>
Value
</someChild>
<someChild>
<someGrandChild>Value</someGrandChild>
</someChild>
<someOtherChild>
Value
</someOtherChild>
</someElem>
</root>
and then the base XML looks something like:
Code:
<?xml version='1.0'?>
<root>
<someElem>
<someChild>
<someGrandChild>Value</someGrandChild>
</someChild>
<someChild>
Value
</someChild>
<includeOtherFileHere>
<fileToInclude>/path/to/file.xml</fileToInclude>
</includeOtherFileHere>
<someOtherChild>
Value
</someOtherChild>
<stillSomeOtherChild>
Value
</stillSomeOtherChild>
</someElem>
</root>
and when the XSL matches //includeOtherFileHere, I want to do something like:
Code:
<xsl:template match="//includeOtherFileHere">
<!-- TODO get actual value of file path attribute -->
<xsl:value-of select="document('/path/to/file.xml')" />
</xsl:template>
but all other elements, I simply want to copy verbatim... so the resulting XML would look like:
Code:
<?xml version='1.0'?>
<root>
<someElem>
<someChild>
<someGrandChild>Value</someGrandChild>
</someChild>
<someChild>
Value
</someChild>
<someElem>
<someChild>
Value
</someChild>
<someChild>
<someGrandChild>Value</someGrandChild>
</someChild>
<someOtherChild>
Value
</someOtherChild>
</someElem>
<someOtherChild>
Value
</someOtherChild>
<stillSomeOtherChild>
Value
</stillSomeOtherChild>
</someElem>
</root>
the problem being... I don't necessarily know the names of the other elements (I may need to match //someOtherChild, or I may need to match //stillSomeOtherChild, or I may need to match some as-yet-unspec'd node name).
What's the most efficient way to perform the value-of of an external document if I match //includeOtherFileHere, otherwise copy the node (and any children) exactly?
It just isn't clicking for me today.
Thanks in advance!
-Carl