Namespace prefix in XSD

Discussion in 'XML' started by Tanja Schaettler, Nov 17, 2006.

  1. Hello!

    I have an existing SOAP message which looks like:

    <?xml version="1.0" encoding="UTF-8" ?>
    <SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
    <xsi:MaintainCTOBomResponse
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <return xsi:type="xsd:string">...

    and I need to define an XSD for it.

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsi:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <xsd:element name="Envelope">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Body" form="qualified">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="MaintainCTOBomResponse">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="return">
    <xsd:complexType>
    <xsd:sequence>
    ...
    <xsd:attribute name="type"/>

    When I validate the XML with XML Spy it says: "Mandatory element
    'MaintainCTOBomResponse' expected in place of 'xsi:MaintainCTOBomResponse'".

    I cannot change the XML, how can I add the namespace prefix in the XSD
    so that the xsi:MaintainCTOBomResponse element and the return xsi:type
    attribute can successfully be validated? Thanks for your help.


    Regards, Tanja
     
    Tanja Schaettler, Nov 17, 2006
    #1
    1. Advertising

  2. Hi,

    It is not possible to define more than one namespace within a single xml
    schema. However, it is possible to reuse an xml schema with a different
    namespace by importing it:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:prefix="---namespace-of-MaintainCTOBomResponse---">
    <xsd:import namespace="---namespace-of-MaintainCTOBomResponse---"
    schemaLocation="---schema-with-MaintainCTOBomResponse---.xsd"/>
    <xsd:element name="Envelope">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Body" form="qualified">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="prefix:MaintainCTOBomResponse"/>

    Gerben Abbink
    www.xmlblueprint.com


    "Tanja Schaettler" <> wrote in message
    news:ejkr1e$6tl$...
    >
    > Hello!
    >
    > I have an existing SOAP message which looks like:
    >
    > <?xml version="1.0" encoding="UTF-8" ?>
    > <SOAP-ENV:Envelope
    > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    > <SOAP-ENV:Body>
    > <xsi:MaintainCTOBomResponse
    > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    > <return xsi:type="xsd:string">...
    >
    > and I need to define an XSD for it.
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <xsi:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    > <xsd:element name="Envelope">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element name="Body" form="qualified">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element name="MaintainCTOBomResponse">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element name="return">
    > <xsd:complexType>
    > <xsd:sequence>
    > ...
    > <xsd:attribute name="type"/>
    >
    > When I validate the XML with XML Spy it says: "Mandatory element
    > 'MaintainCTOBomResponse' expected in place of
    > 'xsi:MaintainCTOBomResponse'".
    >
    > I cannot change the XML, how can I add the namespace prefix in the XSD so
    > that the xsi:MaintainCTOBomResponse element and the return xsi:type
    > attribute can successfully be validated? Thanks for your help.
    >
    >
    > Regards, Tanja
     
    Gerben Abbink, Nov 23, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. heidi

    Tag prefix and namespace

    heidi, Nov 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    380
    heidi
    Nov 2, 2003
  2. =?Utf-8?B?c29tYXNsZWVw?=

    namespace prefix

    =?Utf-8?B?c29tYXNsZWVw?=, Jun 10, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    433
    =?Utf-8?B?c29tYXNsZWVw?=
    Jun 10, 2004
  3. Tim Tyler
    Replies:
    36
    Views:
    1,536
    Darryl L. Pierce
    Dec 10, 2004
  4. Thea
    Replies:
    6
    Views:
    2,076
  5. Chris  Chiasson
    Replies:
    6
    Views:
    658
    Richard Tobin
    Nov 14, 2006
Loading...

Share This Page