Thursday, 12 September 2013

XML to XML conversion - Modifying multiple words within a text

XML to XML conversion - Modifying multiple words within a text

I have been taking help from here often on various technologies. Asking
question for the first time though. Recently started using XML technology
at workplace. Stuck up at a crucial point. Actually I was working on XML
to XML conversion using XSLT 1.0.
The input xml looks like this:
<front>
<funding-group>
<award-group id="award1">
<funding-source id="GS1">A</funding-source>
<award-id rid="GS1">1</award-id>
</award-group>
<award-group id="award2">
<funding-source id="GS2">B</funding-source>
<funding-source id="GS3">C</funding-source>
<award-id rid="GS2 GS3">2</award-id>
</award-group>
</funding-group>
</front>
<body>
<p>This work was supported by the 9 Program Grant 1, A 309 and 311, and B,
C Grant 2.</p>
</body>
I need to convert this to below(note:funding-source becomes grant-sponsor,
award-id becomes grant-num and "funding-group" has been removed):
Output xml:
<body>
<p>This work was supported by the 9 Program Grant
<grant-num>1</grant-num>, <grant-sponsor>A</grant-sponsor> 309 and 311,
and the <grant-sponsor>B</grant-sponsor>, <grant-sponsor>C</grant-sponsor>
Grant <grant-num>2</grant-num>.</p>
</body>
Tried using string-replace as well as regex but couldn't succeed fully.
Really need your help guys.. Thanks..

No comments:

Post a Comment