So our data has xmlns=
in a child/parent that is stopping the child's value from being updated by the XSLT
Sample Data (Please note I intentionally removed the xmlns="http://example.com/abc-artifact"
from the second record, after <Letter
to illustrate that it is what is causing the error):
<Documents>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PersonalData>
<Name>JACK</Name>
</PersonalData>
<DocumentXml>
<Letter xmlns="http://example.com/abc-artifact" xsi:schemaLocation="http://example.com/abc-artifact.xsd" xsi:type="LetterType">
<HeaderRecord>
<DateOfBirth>1971-11-07</DateOfBirth>
</HeaderRecord>
</Letter>
</DocumentXml>
</Document>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PersonalData>
<Name>TONJA</Name>
</PersonalData>
<DocumentXml>
<Letter xsi:schemaLocation="http://example.com/abc-artifact.xsd" xsi:type="LetterType">
<HeaderRecord>
<DateOfBirth>1974-22-10</DateOfBirth>
</HeaderRecord>
</Letter>
</DocumentXml>
</Document>
</Documents>
XSLT
<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="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="DateOfBirth">
<xsl:copy>
<xsl:text>NewDOB</xsl:text>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output
<Documents>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PersonalData>
<Name>JACK</Name>
</PersonalData>
<DocumentXml>
<Letter xmlns="http://example.com/abc-artifact">
<HeaderRecord>
<DateOfBirth>1971-11-07</DateOfBirth>
</HeaderRecord>
</Letter>
</DocumentXml>
</Document>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PersonalData>
<Name>TONJA</Name>
</PersonalData>
<DocumentXml>
<Letter>
<HeaderRecord>
<DateOfBirth>NewDOB</DateOfBirth>
</HeaderRecord>
</Letter>
</DocumentXml>
</Document>
</Documents>
So you can see the <DateOfBirth>
updated for the second record, but not the first. Our team does not control the data and cannot ask them to remove the xmlns="http://example.com/abc-artifact"
. Any suggestions? Thanks