I'm attempting to add a child node referencing another child node. In the below example I'd like to populate <AcctID>
from <AcctDtl>
into <Position>
. I'm doing this as MS-Access only imports child nodes into separate tables without a way of referencing/linking the tables.
<AcctFncl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="fsrv" xsi:schemaLocation="fsrv Rec.xsd" Version="27">
<CreateDate>20151101</CreateDate>
<EffectDate>20151031</EffectDate>
<FnclRec>
<AcctDtl>
<MgmtCode>XXX</MgmtCode>
<AcctID>123980</AcctID>
</AcctDtl>
<Position>
<FundID>5268</FundID>
<TotalUnAssigned>50</TotalUnAssigned>
<TotalAssigned>0</TotalAssigned>
<AveCost>10</AveCost>
<DivOpt>1</DivOpt>
</Position>
</FnclRec>
</AcctFncl>
should look like:
<AcctFncl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="fsrv" xsi:schemaLocation="fsrv Rec.xsd" Version="27">
<CreateDate>20151101</CreateDate>
<EffectDate>20151031</EffectDate>
<FnclRec>
<AcctDtl>
<MgmtCode>XXX</MgmtCode>
<AcctID>123980</FundAcctID>
</AcctDtl>
<Position>
<AcctID>123980</AcctID>
<FundID>5268</FundID>
<TotalUnAssigned>50</TotalUnAssigned>
<TotalAssigned>0</TotalAssigned>
<AveCost>10</AveCost>
<DivOpt>1</DivOpt>
</Position>
</FnclRec>
</AcctFncl>
I've been trying to create a XSLT to do this but I think I'm in over my head here.
<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="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Position">
<FundPosition>
<AcctID><xsl:value-of select="../AcctDtl/CreateDate"/></AcctID>
<xsl:apply-templates select="@*|node()"/>
</FundPosition>
</xsl:template>
</xsl:stylesheet>