I would like to transform a sourcefile that has the namespace
xmlns:psi213="http://www.abb.com/printing/printProductImport/abc"
to a target XML file that has only the namespace
xmlns:psi213="http://www.abb.com/printing/printProductImport"
The two namespaces do actually contain the same, it was just for whatever reason renamed in the sourcefiles, which I cannot change now.
Source XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<printProduct xmlns="http://www.abb.com/printing/printProductImport/abc" name="myname" newspaperName="ef" publicationDate="2012-05-01" creationTime="2012-05-01T11:48:56" version="1" creator="eb" comment="TB_20020501">
<book name="Principal" physicalBookNumber="1" processing="NONE"/>
<book name="Supplement" physicalBookNumber="4" processing="STITCH"/>
<simplePage name="UNECDA" pagination="1.1" physicalPageNumber="1" pageFormat="TABLOID" comment="Reserve"
attachedData="numberOfPageparts=1;destination=;NumberOfPlates=0;PressName=OF1-GUINGAMP-1/48-T4RD;specialTreatment=QN;pagePairing=1;layout=GPNORMAL;platePagination=1;prefixNumber=P01;MasterEdition=CDA_SAINT-BRIEUC;master=0">
<colorSeparation color="4-NOIR"
id="181"/>
<colorSeparation color="4-JAUNE"
id="182"/>
<colorSeparation color="4-MAGENTA"
id="183"/>
<colorSeparation color="4-CYAN"
id="184"/>
</simplePage>
</printProduct>
My Transform
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:psi213="http://www.abb.com/printing/printProductImport/abc"
xmlns="http://www.abb.com/printing/printProductImport">
<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" indent="no" xmlns="http://www.abb.com/printing/printProductImport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
I cannot change anything in the sourcefile, but the target file should be without the /abc in the namespace.
I had expected to see only the namespace I give in the <xsl:output xmlns=""> line to appear in the output. But what I get has the namespace after every element that is not specifically affected by the transform, instead transformed using the template:
Code:
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
I think I could specifically transform "EVERY" element, which would then omit the namespace line, but I don't think this is the optimum solution.
The output I get is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<printProduct name="myname" newspaperName="ef" publicationDate="2012-05-01" creationTime="2012-05-01T11:48:56" version="1" creator="eb" comment="TB_20020501" xmlns="http://www.abb.com/printing/printProductImport">
<printProductDescription structure="T48.T16">
<book name="Principal" physicalBookNumber="1" processing="NONE" xmlns="http://www.abb.com/printing/printProductImport/abc" />
<book name="Supplement" physicalBookNumber="4" processing="STITCH" xmlns="http://www.abb.com/printing/printProductImport/abc" />
<simplePage name="UNECDA" pagination="1.1" physicalPageNumber="1" pageFormat="TABLOID" comment="Reserve">
<colorSeparation color="4-NOIR" id="181" xmlns="http://www.abb.com/printing/printProductImport/abc" />
<colorSeparation color="4-JAUNE" id="182" xmlns="http://www.abb.com/printing/printProductImport/abc" />
<colorSeparation color="4-MAGENTA" id="183" xmlns="http://www.abb.com/printing/printProductImport/abc" />
<colorSeparation color="4-CYAN" id="184" xmlns="http://www.abb.com/printing/printProductImport/abc" />
</simplePage>
This means that the namespace of the file is fine, but I do not need the namespace info for every element. I already tried exclude namespace psi213 what I understood was the recommendation in another post, but the result was the same. Does anybody know what I am missing here? I use MSXML 4.0 on Windows 2003 Server