RE: [xsl] exclude-result-prefixes issue

Subject: RE: [xsl] exclude-result-prefixes issue
From: "Matt Frank" <mfrank@xxxxxxxxxxx>
Date: Wed, 26 May 2004 21:19:05 -0500
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
Senior Technical Project Manager
* P 972-543-7953
* C 469-441-8687
* F 972-543-8002
* mfrank@xxxxxxxxxxx
H 2740 N. Dallas Parkway Suite 140 
Plano, TX 75093 




-----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