xsl-list
[Top] [All Lists]

RE: exclude-result-prefixes issue

2004-05-26 21:13:17
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=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:xsd=&quot;http://www.w3.org/1999/XMLSchema&quot;
xmlns:xsi=&quot;http://www.w3.org/1999/XMLSchema-instance&quot;
SOAP-ENV:encodingStyle=&quot;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(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)mhk(_dot_)me(_dot_)uk] 
Sent: Wednesday, May 26, 2004 6:14 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--




--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--