Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2012, 03:44 AM
Registered User
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Changing namespace url from source xml in target xml

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to include namespace in the target xml in a simple way? spring2009 XSLT 1 September 9th, 2010 10:46 AM
Transform xml to xml changing one tag. surfer97301 XSLT 2 April 21st, 2010 05:14 PM
convert XML to XMl - Another Namespace question bonekrusher XSLT 2 July 10th, 2007 07:32 AM
Converting Source Xml into Target Xml Using XSL. alapati.sasi XSLT 3 May 14th, 2007 10:54 AM
Ignoring namespace in source XML Chamkaur XSLT 1 June 16th, 2006 03:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.