Sateesh
Sateesh

Reputation: 53

The prefix "xsi" for attribute "xsi:type" associated with an element type is not bound

I wrote XSLT, but I'm getting the following error:

The prefix xsi for attribute xsi:type associated with an element type RemoteException is not bound.

My input XML is

<RemoteException xsi:type='ns1:Exception' xmlns:ns1='http://errorhandling.service.e2e.de'>
     <causeClass xsi:type='xsd:string'>de.common.exception.StringLengthException</causeClass>
     <causeMessage xsi:type='xsd:string'>lfdNr has invalid length: 11 (min: 14, max: 14, content: '035593111P0')</causeMessage>
     <causeStackTrace xsi:type='xsd:string'>at)</causeStackTrace>
     <errorCode xsi:type='xsd:int'>201</errorCode>
     <message xsi:type='xsd:string'>invalid length</message>
    </RemoteException>

XSLT Code

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl soap response ns1   xsi" 

xmlns:response="http://tempuri.org/" 

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ns1="http://errorhanlding.service.e2e..de" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <!-- Output -->
   <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
   <xsl:strip-space elements="*"/>
   <xsl:template match="/">

     <xsl:if test="//RemoteException">
         <Fault_MT_Test>
            <standard>
               <faultText>
                  <xsl:value-of select="//faultstring"/>
               </faultText>
               <faultUrl>
                  <xsl:value-of select="//faultcode"/>
               </faultUrl>
            </standard>
         </Fault_MT_Test>
      </xsl:if>

   </xsl:template>
</xsl:stylesheet>

Could you please explain to me what this error means and how to eliminate it?

Upvotes: 1

Views: 5059

Answers (1)

kjhughes
kjhughes

Reputation: 111756

XML namespace prefixes such as xsi must be defined; otherwise, the XML is not namespace-well-formed. It doesn't matter that you don't control the XML. Either tell those upstream of you to fix it (it is undeniably broken), or fix it yourself.

To declare xsi, add the following: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance".

See also

Upvotes: 3

Related Questions