Subject: RE: [xsl] exclude-result-prefixes issue From: "Matt Frank" <mfrank@xxxxxxxxxxx> Date: Wed, 26 May 2004 23:13:17 -0500 |
Please disregard my last question. I have managed to make it a little further. My problem now is my output looks like <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <MCF-ENV:MCFSOAPHeader xmlns:MCF-ENV="http://www.MCFmarket.com/soap/"> <MCF-ENV:MCFSenderID>1000004310</MCF-ENV:MCFSenderID> <MCF-ENV:MCFReceiverID>Sender</MCF-ENV:MCFReceiverID> <MCF-ENV:transactionTimestamp>2004-05-25 10:47:13</MCF-ENV:transactionTimestamp> <MCF-ENV:logicalIdentifier>NA</MCF-ENV:logicalIdentifier> <MCF-ENV:businessDocIDs>5000010243</MCF-ENV:businessDocIDs> <MCF-ENV:messageState>Inbound</MCF-ENV:messageState> </MCF-ENV:MCFSOAPHeader> </SOAP-ENV:Header> <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <MCF-ENV:MCFSOAPBody xmlns:MCF-ENV="http://www.MCFmarket.com/soap/"> <MCF-ENV:businessDocID>5000010243</MCF-ENV:businessDocID> <MCF-ENV:MCFMessageType>MCFPurchaseOrder</MCF-ENV:MCFMessageType> <MCF-ENV:messageFormat>xCBL</MCF-ENV:messageFormat> <MCF-ENV:messageContainer>Order</MCF-ENV:messageContainer> <MCF-ENV:businessDoc> </MCF-ENV:businessDoc> </MCF-ENV:MCFSOAPBody> </SOAP-ENV:Body> </SOAP-ENV:Envelope> And I need <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <MCF-ENV:MCFSOAPHeader xmlns:MCF-ENV="http://www.MCFmarket.com/soap/"> <MCF-ENV:MCFSenderID>1000004310</MCF-ENV:MCFSenderID> <MCF-ENV:MCFReceiverID>Sender</MCF-ENV:MCFReceiverID> <MCF-ENV:transactionTimestamp>2004-05-25 10:47:13</MCF-ENV:transactionTimestamp> <MCF-ENV:logicalIdentifier>NA</MCF-ENV:logicalIdentifier> <MCF-ENV:businessDocIDs>5000010243</MCF-ENV:businessDocIDs> <MCF-ENV:messageState>Inbound</MCF-ENV:messageState> </MCF-ENV:MCFSOAPHeader> </SOAP-ENV:Header> <SOAP-ENV:Body> <MCF-ENV:MCFSOAPBody xmlns:MCF-ENV="http://www.MCFmarket.com/soap/"> <MCF-ENV:businessDocID>5000010243</MCF-ENV:businessDocID> <MCF-ENV:MCFMessageType>MCFPurchaseOrder</MCF-ENV:MCFMessageType> <MCF-ENV:messageFormat>xCBL</MCF-ENV:messageFormat> <MCF-ENV:messageContainer>Order</MCF-ENV:messageContainer> <MCF-ENV:businessDoc> </MCF-ENV:businessDoc> </MCF-ENV:MCFSOAPBody> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Essentially I just need to drop the namespace on the <SOAP-ENV:Body> element. Output is <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> And I need <SOAP-ENV:Body> How do I remove the one namespace. Below is my code: <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope" xmlns:MCF-ENV = "http://www.MCFmarket.com/soap/" exclude-result-prefixes = "MCF-ENV SOAP-ENV"> <xsl:output method = "xml" version = "1.0" encoding = "UTF-8" indent = "yes"/> <xsl:param name = "senderid"/> <xsl:param name = "receiverid"/> <xsl:param name = "dateTime"/> <xsl:param name = "documentid"/> <xsl:template match = "Order"> <xsl:element name = "SOAP-ENV:Envelope" namespace = "xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/&q uot;"> <xsl:element name = "SOAP-ENV:Header"> <xsl:element name = "MCF-ENV:MCFSOAPHeader"> <xsl:element name = "MCF-ENV:MCFSenderID"> <xsl:value-of select = "$senderid"/> </xsl:element> <xsl:element name = "MCF-ENV:MCFReceiverID"> <xsl:value-of select = "$receiverid"/> </xsl:element> <xsl:element name = "MCF-ENV:transactionTimestamp"> <xsl:value-of select = "$dateTime"/> </xsl:element> <xsl:element name = "MCF-ENV:logicalIdentifier"> <xsl:text>NA</xsl:text> </xsl:element> <xsl:element name = "MCF-ENV:businessDocIDs"> <xsl:value-of select = "$documentid"/> </xsl:element> <xsl:element name = "MCF-ENV:messageState"> <xsl:text>Inbound</xsl:text> </xsl:element> </xsl:element> </xsl:element> <xsl:element name = "SOAP-ENV:Body"/> <xslFrom xsl-list-return-2300-archive-lists.mulberrytech.com-xsl-list=biglist.com@xxxxxxxxxxxxxxxxxxxxxx Thu May 27 01:28:56 2004 Received: from h01.biglist.com (h01.biglist.com [209.123.46.101]) by biglist.com (8.8.8/8.8.5/BL-2) with SMTP id BAA02057 for <archive-lists.mulberrytech.com-xsl-list@xxxxxxxxxxx>; Thu, 27 May 2004 01:28:55 -0400 (EDT) Received: (qmail 11635 invoked by uid 2149); 27 May 2004 05:28:35 -0000 Mailing-List: contact xsl-list-help@xxxxxxxxxxxxxxxxxxxxxx Precedence: bulk X-BL-Legal-Notice: <http://www.BIGLIST.com/legal/> X-Complaints-To: <mailto:abuse@xxxxxxxxxxx> List-Post: <mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> List-Help: <mailto:xsl-list-help@xxxxxxxxxxxxxxxxxxxxxx> List-Unsubscribe: <mailto:xsl-list-unsubscribe-archive-lists.mulberrytech.com-xsl-list=biglist.com@xxxxxxxxxxxxxxxxxxxxxx> List-Subscribe: <mailto:xsl-list-subscribe@xxxxxxxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Delivered-To: mailing list xsl-list@xxxxxxxxxxxxxxxxxxxxxx Received: (qmail 11623 invoked from network); 27 May 2004 05:28:35 -0000 Message-ID: <000b01c443ab$73826310$b1e8c08d@xxxxxxxxxxxxxxxx> From: "Kaarle Kaila" <kaarle.kaila@xxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> References: <40B55443.5060603@xxxxxxxxxxxx> Date: Thu, 27 May 2004 08:28:32 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook Express 6.00.2800.1158 Subject: Re: [xsl] CLARIFICATION ON NAMESPACE You must include the namespace prefixe to the names for the elements. In your example the title was not in the namespaces you intended. Here you must use the namespace prefixes <?xml-stylesheet type="text/xsl" href="main.xsl"?> <root> <head xmlns:fa="http://www.test.com/element-a"> <fa:title>I am in file 'fa'</fa:title> </head> <head xmlns:fb="http://www.test.com/element-b"> <fb:title>I am in file 'fb'</fb:title> </head> </root> or use the default namespace like this. <?xml-stylesheet type="text/xsl" href="main.xsl"?> <root> <head xmlns="http://www.test.com/element-a"> <title>I am in file 'fa'</title> </head> <head xmlns="http://www.test.com/element-b"> <title>I am in file 'fb'</title> </head> </root> ----- Original Message ----- From: "Arul Kumar" <arulxml@xxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Thursday, May 27, 2004 5:36 AM Subject: [xsl] CLARIFICATION ON NAMESPACE > Hello all, > > Greetings > > My xml having the root element called 'root', two child elements 'head', > both the head element having the namespace declaration 'fa' and 'fb' > respectively, and having the child called 'title'. > > In my memory, some time ago I read about the namespace declaration as > 'The namespace declaration given for the current element is also valid > for all children and descendants'. According to this, can I able to > treat (in XSL) the 'title' element as 'fa:title' and 'fb:title'? > > When I do so, in view the xml in IE, I couldn't see the expected result? > Please find my XML and XSL appended below. > > My XML (test.xml): > > <?xml-stylesheet type="text/xsl" href="main.xsl"?> > <root> > <head xmlns:fa="http://www.test.com/element-a"> > <title>I am in file 'fa'</title> > </head> > <head xmlns:fb="http://www.test.com/element-b"> > <title>I am in file 'fb'</title> > </head> > </root> > > My XSL (main.xsl): > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns="http://www.test.com/xml" > xmlns:fa="http://www.test.com/element-a" > xmlns:fb="http://www.test.com/element-b"> > <xsl:output method="html"/> > <xsl:template match="/"> > <html> > <body> > <p style="color:red">FA: <xsl:value-of > select="string(//*/*/fa:title)"/></p> > <p style="color:blue">FB: <xsl:value-of > select="string(//*/*/fb:title)"/></p> > </body> > </html> > </xsl:template> > </xsl:stylesheet> > > Please advice, how to achieve this? Or my understanding is wrong? Please > share your valuable comments. Many thanks in advance. > > Kind regards > Arul
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] exclude-result-prefixes i, Matt Frank | Thread | RE: [xsl] exclude-result-prefixes i, Michael Kay |
[xsl] CLARIFICATION ON NAMESPACE, Arul Kumar | Date | [xsl] Changing Attribute Value in a, Animesh Sharma |
Month |