J
John Harrison
This is my first XSLT project and I need some guidance on the approach
to take.
The problem is to take a document in one XML format and transform it
into another XML format. The source format is fixed but the
destination format will evolve. The two formats are completely
unrelated, so there are source elements we will ignore and destination
elements we will never receive.
However the management has decreed that we mustn't throw away any
data, since we may modify the destination format in such a way that we
can now accommodate source data that we couldn't previously. Therefore
the destination format contains a catch all area that is designed for
all *unprocessed* source data.
Perhaps an example will make this clear
<source>
<team>
<name>Arsenal</name>
<manager><name><first>Arsene</first><last>Wenger</last></name></manager>
<star-player><name><first>Thierry</first><last>Henri</last></name></star-player>
</team>
</source>
If we aren't interested in the star player this might be transformed
to say
<dest>
<team name="Arsenal">
<manager>Arsene Wenger</manager>
</team>
<unprocessed>
<team>
<star-player><name><first>Thierry</first><last>Henri</last></name></star-player>
</team>
</unprocessed>
</dest>
Notice how the processed portion has been transformed but the
unprocessed portion (including the team tag) has been dumped unchanged
into the unprocessed tag.
So any ideas on what approach can I take to code this in an elegant
and robust way? I want to do some sort of 'catch all' processing that
will automatically recognise which portions of the document are
unprocessed by the rest of my XSLT code.
MTIA
John
to take.
The problem is to take a document in one XML format and transform it
into another XML format. The source format is fixed but the
destination format will evolve. The two formats are completely
unrelated, so there are source elements we will ignore and destination
elements we will never receive.
However the management has decreed that we mustn't throw away any
data, since we may modify the destination format in such a way that we
can now accommodate source data that we couldn't previously. Therefore
the destination format contains a catch all area that is designed for
all *unprocessed* source data.
Perhaps an example will make this clear
<source>
<team>
<name>Arsenal</name>
<manager><name><first>Arsene</first><last>Wenger</last></name></manager>
<star-player><name><first>Thierry</first><last>Henri</last></name></star-player>
</team>
</source>
If we aren't interested in the star player this might be transformed
to say
<dest>
<team name="Arsenal">
<manager>Arsene Wenger</manager>
</team>
<unprocessed>
<team>
<star-player><name><first>Thierry</first><last>Henri</last></name></star-player>
</team>
</unprocessed>
</dest>
Notice how the processed portion has been transformed but the
unprocessed portion (including the team tag) has been dumped unchanged
into the unprocessed tag.
So any ideas on what approach can I take to code this in an elegant
and robust way? I want to do some sort of 'catch all' processing that
will automatically recognise which portions of the document are
unprocessed by the rest of my XSLT code.
MTIA
John