on 03-11-2008 11:10 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mendez,
you have to paste your source XML, that we can solve your problem.
Regards Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.