cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle duplicate nodes in xslt mapping

Former Member
0 Kudos

Hi,

in my scenario that i have a source mapped to the canonical structure and from canonical to target.

source structure

<empid>

<national_id>

canonical structure

<id> 0 to unbounded

<id>

<type>

the mapping from source to canonical

is like i have duplicated the canonical structure and then mapped

id -


empid

type--- assigned a constant employee

id -


national_id

type--- assigned a constant National

i have used xslt mapping using stylus studio and mapping from source to canonical is not the problem

when i mapped the canonical to target there is a problem

the node id is visible once in the canonical when the structure is a source

but there is a dupicate node in the structure but not visible. how to procedue with the mapping for canonical to target

kindly help me

with regards

pradeep N

Accepted Solutions (0)

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Pradeep,

sorry, your task is difficult ot understand.

Can you gibe me an XML example for your issue?

- The source, which you want to map, and

- the result, which you would like to have?

Regards,

Udo

Former Member
0 Kudos

hi,

Udo Martens.

<b>source xml</b>

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

<ns0:Materail_fileReceive xmlns:ns0="http://www.aprilbiztec.in/MM_MultiFile">

<Emp_ID>12</Emp_ID>

<National_ID>91</National_ID>

</ns0:Materail_fileReceive>

<b>canonical xml</b>

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

<ns0:Materail_file xmlns:ns0="http://www.aprilbiztec.in/MM_MultiFile"><Material><ID>12</ID><Type>Employee</Type></Material><Material><ID>91</ID><Type>National</Type></Material></ns0:Materail_file>

<b>source to canonical mapping is</b>

<?xml version='1.0' ?>

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

<xsl:template match="/">

<ns0:Materail_file xmlns:ns0="http://www.aprilbiztec.in/MM_MultiFile">

<Material>

<ID>

<xsl:value-of select="ns0:Materail_fileReceive/Emp_ID"/>

</ID>

<Type>Employee</Type>

</Material>

<Material>

<ID>

<xsl:value-of select="ns0:Materail_fileReceive/National_ID"/>

</ID>

<Type>National</Type>

</Material>

</ns0:Materail_file>

</xsl:template>

i want the<b> canonical to target mapping</b> where my target structure is similar to that of my source

kindly help.

regards

pradeep N.

udo_martens
Active Contributor
0 Kudos

Hi Pradeep,

this should work:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.aprilbiztec.in/MM_MultiFile">
	<xsl:template match="*">
		<ns0:Materail_file>
			<Emp_ID>
				<xsl:value-of select="//ID[../Type='Employee']"/>
			</Emp_ID>
			<National_ID>
				<xsl:value-of select="//ID[../Type='National']"/>
			</National_ID>
		</ns0:Materail_file>
	</xsl:template>
</xsl:stylesheet>

Regards,

Udo