[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] exclude-result-prefixes issue
Subject: RE: [xsl] exclude-result-prefixes issue From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx> Date: Thu, 27 May 2004 16:27:30 -0500 |
Could we see your input XML, Matt? That may be of help to us trying to help you. <prs/> -----Original Message----- From: Matt Frank [mailto:mfrank@xxxxxxxxxxx] Sent: Wednesday, May 26, 2004 11:13 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] exclude-result-prefixes issue 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"/> <xsl:element name = "MCF-ENV:MCFSOAPBody"> <xsl:element name = "MCF-ENV:businessDocID"> <xsl:value-of select = "$documentid"/> </xsl:element> <xsl:element name = "MCF-ENV:MCFMessageType"> <xsl:text>MCFPurchaseOrder</xsl:text> </xsl:element> <xsl:element name = "MCF-ENV:messageFormat"> <xsl:text>xCBL</xsl:text> </xsl:element> <xsl:element name = "MCF-ENV:messageContainer"> <xsl:text>Order</xsl:text> </xsl:element> <xsl:element name = "MCF-ENV:businessDoc"> <xsl:element name = "Order"> <xsl:apply-templates select = "OrderHeader"/> <xsl:call-template name = "OrderDetail"/> <xsl:call-template name = "OrderSummary"/> </xsl:element> </xsl:element> </xsl:element> </xsl:element> </xsl:template> Regards, Matt Frank -----Original Message----- From: Matt Frank Sent: Wednesday, May 26, 2004 9:19 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] exclude-result-prefixes issue My apologies, I agree with you that was not a namespace-well-formed XML document. What I am looking for is to create a Soap Envelope like the following: <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> InsertOrder </MCF-ENV:businessDoc> </MCF-ENV:MCFSOAPBody> </SOAP-ENV:Body> </SOAP-ENV:Envelope> The problem I have is when I declare a namespace for SOAP-ENV and MCF-ENV the namespace gets added to each element I create. So <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> Winds up looking like <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 xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">1000004310</MCF-ENV:MCFSe nderID> <MCF-ENV:MCFReceiverID xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">Sender</MCF-ENV:MCFReceiv erID> <MCF-ENV:transactionTimestamp xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">2004-05-25 10:47:13</MCF-ENV:transactionTimestamp> <MCF-ENV:logicalIdentifier xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">NA</MCF-ENV:logicalIdenti fier> <MCF-ENV:businessDocIDs xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">5000010243</MCF-ENV:busin essDocIDs> <MCF-ENV:messageState xmlns:MCF-ENV="http://www.MCFmarket.com/soap/">Inbound</MCF-ENV:messageS tate> </MCF-ENV:MCFSOAPHeader> </SOAP-ENV:Header> Regards, Matt Frank -----Original Message----- From: Michael Kay [mailto:mhk@xxxxxxxxx] Sent: Wednesday, May 26, 2004 6:14 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] exclude-result-prefixes issue > > I am having a small problem with prefixes. I am trying to build a > soap envelope and am having trouble eliminating namespaces for > elements that > include a prefix. > > I have a very simple stylesheet seen below: > > <?xml version = "1.0" encoding = "UTF-8"?> > <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" > version = "1.0" xmlns:SOAP-ENV = > "http://schemas.xmlsoap.org/soap/envelope" exclude-result-prefixes = > "SOAP-ENV"> > <xsl:template match = "/"> > <xsl:element name = "SOAP-ENV:Envelope"> > <xsl:element name = "SOAP-ENV:Body"/> > </xsl:element> > </xsl:template> > </xsl:stylesheet> exclude-result-prefixes only affects literal result elements. Your stylesheet doesn't contain any literal result elements, so it has no effect. > > The current output is: > > <?xml version = "1.0" encoding = "UTF-8"?> > <SOAP-ENV:Envelope xmlns:SOAP-ENV = > "http://schemas.xmlsoap.org/soap/envelope"> > <SOAP-ENV:Body/> > </SOAP-ENV:Envelope> > > I would like the output to be > > <?xml version = "1.0" encoding = "UTF-8"?> <SOAP-ENV:Envelope> > <SOAP-ENV:Body/> > </SOAP-ENV:Envelope> > That is not a namespace-well-formed XML document, so it cannot be produced using XSLT. Michael Kay
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] exclude-result-prefixes i, Niclas Hedhman | Thread | [xsl] Stylesheet in a Xerces DOM tr, Steve Dussinger |
Re: [xsl] exclude-result-prefixes i, Niclas Hedhman | Date | RE: [xsl] NEED good information on , Pieter Reint Siegers |
Month |
Keywords