xml file import with identitiy transform xslt file

Wysy

Registered User.
Local time
Yesterday, 19:43
Joined
Jul 5, 2015
Messages
333
HI,
I have the following xml file (sample)

<?xml version="1.0" encoding="utf-8"?>
<International xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Country>Hungary</Country>
<Owners>
<Owner>
<OwnerId>1659117</OwnerId>
<OwnerName>XY</OwnerName>
<Address>ALSORET</Address>
<Addr />
<City />
<CountryDesc>HUNGARY</CountryDesc>
<State />
<Zip />
<ZipExt />
<ForeignAddress>6600</ForeignAddress>
<ExpDate>12/31/18</ExpDate>
<Horses>
<Horse>
<RegNumber>3912571</RegNumber>
<Name>IC</Name>
<Color>BAY</Color>
<Gender>STALLION</Gender>
<FoalYear>1997</FoalYear>
</Horse>
<Horse>
<RegNumber>3940646</RegNumber>
<Name>RD</Name>
<Color>PALOMINO</Color>
<Gender>MARE</Gender>
<FoalYear>1999</FoalYear>
</Horse>

I have an xslt file like this to transform
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/">
<dataroot>
<xsl:apply-templates select="@*|node()"/>
</dataroot>
</xsl:template>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="Horses">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>

<xsl:template match="Horse">
<Horse>
<OwnerID><xsl:value-of select="../../OwnerID"/></OwnerID>
<xsl:apply-templates select="@*|node()"/>
</Horse>
</xsl:template>

</xsl:stylesheet>


It creates an OwnerID field in the Horse table but leaves it empty. How do i get this working to add the correct ownerID value?
thank
andrew
 
Found the solution. The OwnerID should be OwnerId than it works...
 

Users who are viewing this thread

Back
Top Bottom