XSLT Conditional creation of destination Node

T

tommalia

I'm trying to write an XSLT to convert an XML document from one schema
to
another.

The destination XML schema has an optional State element. The element
can be
left out, but if it's present it must have a two character code. The
source XML has
a required element of type string that be left blank. My problem is,
if the source node is present but blank, I want to NOT create the
destination Date node. If the source node is populated
then I want the destination node create and populated.

How do I do this?

Currently, I seem to always get the destination node and if the source
was
blank, the destination is comming up blank and causing a schema
validation
error.

In case you can't tell... I'm a complete NEWBIE to XSTL.

I'm currently using Altova MapForce 2006 to do the development.

Someone in another news group recommend the following:
---------------------------------------------------------------------------------------------------
<xsl:template match="source-element-name[text()]">
<result-element-name>
<xsl:value-of select="." />
</result-element-name>
</xsl:template>

<xsl:template match="source-element-name(not(text())]" />
---------------------------------------------------------------------------------------------------


But being so new to both XSLT and Altova's MapForce, I have no idea how
I would include such code in my Mapforce mapping.

Any help would be greatly appreciated.
 
D

Dimitre Novatchev

Read about, understand and use the >xsl:choose> instruction.

Cheers,
Dimitre Novatchev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top