Reputation: 11
First XML:
<Format>
<title>Data Title</title>
<date>Data Date</date>
<Source>Data source</Source>
</Format>
Second XML:
<format:format xmlns:format="http://www.w3.org/1999/XSL/Transform">
<format>
<formatTitle>
<format:text/>
<separator>, </separator>
<formatDate>
<format:text/>
<separator>, </separator>
</formatDate>
<formatSource>
<format:text/>
<separator>. </separator>
</formatSource>
</format>
I want to transform both the XML file using XSL to get the below o/p as:
Data Title, Date Date, Data Source.
The target XML should look like this:
<format>
<formatTitle>Data title, </formatTitle>
<formatDate>Data Date, </formatDate>
<formatSource>Data Source. </formatSource>
</format>
Upvotes: 0
Views: 54
Reputation: 163262
Your second XML (X2) seems to be defining some kind of simple formatting or transformation language (let's call it FL) that controls how the first XML (X1) is to be rendered. Without knowing the syntax or semantics of the FL language, beyond one example of its effect, it's hard to offer very specific coding help (especially as your specimen X2 isn't even well-formed XML).
However, I have found that the best way of tackling this is by writing an XSLT stylesheet S1 that transforms X2 into an XSLT stylesheet S2, and then using S2 to transform X1 into the required output.
But perhaps I have misunderstood completely what you are trying to do. It's not at all clear. For example, we have no idea how much X1 and X2 might vary from the single test case you have shown us.
Upvotes: 1