cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

Former Member
0 Kudos

I would like some help please?

I have an XSLT mapping which is not working properly. When I sue this mapping:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/MT_SEND">

<MT_RECV xmlns:xsl="http:www.test.com/xi">

<Completion>

<JobID><xsl:value-of select="Completion/JobID"/></JobID>

</Completion>

</MT_RECV>

</xsl:template>

</xsl:stylesheet>

I get an error saying that the xml is not well formed.

But when I use this:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<MT_RECV xmlns:xsl="http:www.test.com/xi">

<Completion>

<JobID><xsl:value-of select="MT_SEND/Completion/JobID"/></JobID>

</Completion>

</MT_RECV>

</xsl:template>

</xsl:stylesheet>

I get the following XML which is clearly not right:

<?xml version="1.0" encoding="utf-8"?>

<MT_RECV xmlns:xsl="http:www.test.com/xi"><Completion><JobID><xsl:value-of select="MT_SEND/Completion/JobID"/></JobID></Completion></MT_RECV>

I want to simply select JobID from the source XML?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This will work:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<ns:MT_RECV xmlns:ns="http:www.test.com/xi">

<Completion>

<JobID>

<xsl:value-of select="//Completion/JobID"/>

</JobID>

</Completion>

</ns:MT_RECV>

</xsl:template>

</xsl:stylesheet>

Kind regards

Mikkel

Former Member
0 Kudos

Mikkel,

That did work... Could you please explain to me why and what I was doing wrong.

So i know what to look for in the future?

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Mendez,

you made a name space with out declaring it. Therefor I added ns: to MT_RECV. That fixes that.

If you want to explisit reference your target with in the namespace you have made like value-of select"/ns0:MT_SEND/Completion/JobID" you need to add: xmlns:ns0="urn:in005.com/xi" exclude-result-prefixes="ns0" to your <xsl:stylesheet top section

Kind regards

Mikkel

P.S. It seems that you in general forget to give points for your questions. That is not the best way to get quick replys from some of the active users.

Edited by: Mikkel Iversen on Mar 11, 2008 2:01 PM

Former Member
0 Kudos

Mikkel,

Ok thank you. By the way when I put the MT_SEND in my match section of the code template part...

It comes up with XML not well formed. Is that also caused by not putting this in?

:ns0="urn:in005.com/xi" exclude-result-prefixes="ns0"

sorry about the points.. awarding them now...

Former Member
0 Kudos

oh sorry:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_SEND xmlns:ns0="urn:in005.com/xi">

<Completion>

<JobID>aaa</JobID>

<ItemActioned/>

<ItemAction/>

<DateOfVisit/>

<QuantityCompleted/>

<Comments/>

</Completion>

</ns0:MT_SEND>

it seems as though it is treating the value of as an element and the select as an attribute of that element with the XPATH as static text?

this is in the second example I am talking about... the first I have no idea about? Although I would like to know why the first is saying not well formed when I add the tag to match as well please?

Former Member
0 Kudos

Hi Mendez,

you have to paste your source XML, that we can solve your problem.

Regards Mario