sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
tommalia's Avatar

XSLT Conditional creation of destination Node


Question posted by: tommalia (Guest) on July 14th, 2006 03:55 PM
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.

1 Answer Posted
Dimitre Novatchev's Avatar
Dimitre Novatchev July 15th, 2006 05:15 AM
Guest - n/a Posts
#2: Re: XSLT Conditional creation of destination Node

Read about, understand and use the >xsl:chooseinstruction.

Cheers,
Dimitre Novatchev

"tommalia" <tommalia@tandtdatasolutions.comwrote in message
news:1152889396.949112.78030@m79g2000cwm.googlegro ups.com...
Quote:
Originally Posted by
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.
>



 
Not the answer you were looking for? Post your question . . .
197,028 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,028 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors