473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XSLT Conditional creation of destination Node

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.

Jul 14 '06 #1
1 1825
Read about, understand and use the >xsl:chooseinstruction.

Cheers,
Dimitre Novatchev

"tommalia" <to******@tandtdatasolutions.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
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.

Jul 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
1
by: Bartek | last post by:
Hello This is my problem: It consider xml 2 xml conversion. source document had unknown structure (xhtml), xslt must process every node, attribute, text, comments etc. from source and write in...
4
by: David Blickstein | last post by:
I have an application where I have a shared "method" of selecting a nodeset. The method currently is duplicated everywhere it is needed but I'd like that code to be shared. The method also...
4
by: gualtmacchi | last post by:
I'm processing an XML input file getting a plain text file where from M nodes I got N output lines... It's not relevant but the input file is a recordset coming from a database and the output is...
1
by: Daniel Hilgarth | last post by:
Hello, I am currently trying to use XSLT for the creation of multiple HTML-files from a single XML-File. This HTML-files need to have links to each other. The following information might be...
8
by: Hercules Dev. | last post by:
Hi all, I'm new in xslt and xpath, so my question might be simple but i'm learning. I have an XML document and need to transform it into another XML, I use xslt and it works, but there is a...
21
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.