I have the following xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en">
<gmd:GEMINI_Metadata xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<itemName Sync="TRUE">Wrong Title</itemName>
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:abstract>
<gco:CharacterString>AbstractText.</gco:CharacterString>
</gmd:abstract>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Correct Title</gco:CharacterString>
</gmd:title>
</gmd:CI_Citation>
</gmd:citation>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
</gmd:GEMINI_Metadata>
</metadata>
I am trying to replace the text "Wrong Title" from the itemName tag with the text "Correct Title" from the gmd:title/gco:CharacterString tag.
I've tried to use the following xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<!--IDENTITY TRANSFORMATION TEMPLATE NEEDED-->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="itemName">
<itemName Sync="TRUE">
<xsl:copy-of select="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString"/>
</itemName>
</xsl:template>
</xsl:stylesheet>
So the resulting xml should look like this
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en">
<itemName Sync="TRUE">Correct Title</itemName>
<gmd:GEMINI_Metadata xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:abstract>
<gco:CharacterString>AbstractText.</gco:CharacterString>
</gmd:abstract>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Correct Title</gco:CharacterString>
</gmd:title>
<gmd:MD_DataIdentification>
<gmd:identificationInfo>
</gmd:GEMINI_Metadata>
</metadata>
but it does not change. What is the best way to achieve this.
itemName. There is no way it can pass the entire output unchanged.