xml for element中未添加前缀

时间:2017-04-26 17:00:03

标签: xml

即使elementFormDefault =" qualified"我也无法获得ihtsoaRequest的前缀。我的XSD如下所示

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema
  version="2.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  targetNamespace="ihtsoa-c-all"
  xmlns:isc="ihtsoa-c-all"
  xmlns:ib="ihtbase"

   >
 <xs:import namespace="ihtbase" schemaLocation="http://gisla-pn2/xsd-common/ihtBase.xsd"/>

  <xs:simpleType name="operation">
    <xs:restriction base="xs:string">
      <xs:enumeration value="storeQosCalculation" />
    </xs:restriction>
  </xs:simpleType>

  <!--<xs:simpleType name="client_type">
    <xs:annotation>
      <xs:documentation>Client C-All will call directly to IHTSOA</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="C-All" />
    </xs:restriction>
  </xs:simpleType> -->

  <xs:simpleType name="clients">
    <xs:union memberTypes="ib:clients isc:cAllClients"/>
 </xs:simpleType>

 <xs:simpleType name="statusCodes">
  <xs:union memberTypes="ib:statusCodes isc:cAllStatusCodes"/>
 </xs:simpleType>

 <xs:simpleType name="cAllClients">
   <xs:restriction base="xs:string">
   <xs:enumeration value="visitation"/>
   </xs:restriction>
</xs:simpleType>

<xs:simpleType name="cAllStatusCodes">
  <xs:restriction base="xs:int">
  <xs:enumeration value="103"/>
  </xs:restriction>
</xs:simpleType>


  <xs:complexType name="request_header_type">
    <xs:complexContent>
    <xs:extension base="ib:header">
    <xs:attribute name="clientId" type="isc:clients" use="required"/>
    <xs:attribute name="clientAuthentication" type="xs:string" use="required"/>
    </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="response_header_type">
    <xs:complexContent>
    <xs:extension base="ib:header">
    <xs:attribute name="statusCode" type="isc:statusCodes" use="required"/>
    <xs:attribute name="statusMessage" type="ib:statusMessages" use="required"/>
    </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="store_qos_calculation_type">
    <xs:annotation>
      <xs:documentation>The two contained elements are base64-encoded representations of the xml-request and 
-response from the C-All communication with CU.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="cAllRequest" type="xs:string" maxOccurs="1" minOccurs="1" />
      <xs:element name="cAllResponse" type="xs:string" maxOccurs="1" minOccurs="1" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="request_type">
    <xs:sequence>
      <xs:element name="header" type="isc:request_header_type" maxOccurs="1" minOccurs="1" />
      <xs:element name="storeQosCalculationRequest" type="isc:store_qos_calculation_type" maxOccurs="1" minOccurs=
"1" />
    </xs:sequence>
    <xs:attribute name="operation" type="isc:operation" use="required"/>
  </xs:complexType>

  <xs:complexType name="response_type">
    <xs:annotation>
      <xs:documentation>The store_qos_calculation_error element is intended for extended error information in the 
case the operation fails</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="header" type="isc:response_header_type" maxOccurs="1" minOccurs="1" />
      <xs:choice>
        <xs:element name="storeQosCalculationResponse" type="isc:store_qos_calculation_type" />
        <xs:element name="storeQosCalculationError" type="xs:string" />
      </xs:choice>
    </xs:sequence>
    <xs:attribute name="operation" type="isc:operation" use="required"/>
  </xs:complexType>

  <!-- Root Element -->
  <xs:element name="ihtsoaRequest"  type="isc:request_type" />
  <xs:element name="ihtsoaResponse" type="isc:response_type" />
</xs:schema>

以下是生成的示例请求

<?xml version="1.0" encoding="ISO-8859-1"?>
<ihtsoaRequest xmlns:ns0="ihtsoa-c-all" operation="storeQosCalculation">
   <ns0:header userId="user" trackingId="1493205978720" companyId="PQR" clientId="abc" clientAuthentication="password"/>
   <ns0:storeQosCalculationRequest>
      <ns0:cAllRequest>ABC</ns0:cAllRequest>
      <ns0:cAllResponse>XYZ</ns0:cAllResponse>
   </ns0:storeQosCalculationRequest>
</ihtsoaRequest>

但是我需要 ihtsoaRequest 标记以ns0为前缀,即 ns0:ihtsoaRequest 。我被困在这里,无法弄明白。能否请你在这里给我建议和帮助。

0 个答案:

没有答案