none
Can I set a specific xmlns value for one single element in an XSD?

    Pregunta

  • Hello,

    Can someone tell me if I can set an xmlns value for one specfic element in my xsd?

    Here is a snippet of what is being returned from the endpoint when I issue the webservice request.

    ....<GetFacilityInfoResult><Facility xmlns="http://cameron.ca"> ....       

    My XSD is expecting something like:

    ....<GetFacilityInfoResult><Facility xmlns=http://tempuri.org>   .....  

    Is there some way I can change my xsd so that it expects the "cameron.ca", rather than "tempuri.org" value?

    I am a little new at this, so if I am asking a foolish question.................

    Thanks


    Cameron Conacher

    sábado, 10 de marzo de 2012 1:41

Respuestas

  • These files are fairly large. Can I send them somewhere?

    We should be able to solve that by exchanging the relevant parts here in the forum.

    For instance if you currently have one schema with

      targetNamespace="http://cameron.ca"

    and a second one with

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

      xmlns:ca="http://cameron.ca">

      <xs:import namespace="http://cameron.ca" schemaLocation="schema1.xsd"/>

    which somewhere does

      <xs:element name="GetFacilityInfoResult">

         <xs:complexType>

            <xs:sequence>

              <xs:element ref="ca:Facility"/>

    then you would need to change the targetNamespace of the first schema to say

      targetNamespace="http://tempuri.org"

    and of course change the import in the second schema as well

        <xs:import namespace="http://tempuri.org" schemaLocation="schema1.xsd"/>

    If the xs:import does not have a namespace attribute then it is easier, you only have to change the targetNamespace in the first schema.


    MVP Data Platform Development My blog

    • Marcado como respuesta Cameron_C martes, 13 de marzo de 2012 14:43
    domingo, 11 de marzo de 2012 11:20

Todas las respuestas

  • Do you want us to tell you where and how to edit your schema(s)? In that case we need to see the relevant code of the schema(s). Generally schemas work per namespace so with your sample XML using at least two namespaces I would expect you to have at least two schemas.

    MVP Data Platform Development My blog

    sábado, 10 de marzo de 2012 10:49
  • Thanks Martin,

    These files are fairly large. Can I send them somewhere?


    Cameron Conacher

    sábado, 10 de marzo de 2012 23:38
  • These files are fairly large. Can I send them somewhere?

    We should be able to solve that by exchanging the relevant parts here in the forum.

    For instance if you currently have one schema with

      targetNamespace="http://cameron.ca"

    and a second one with

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

      xmlns:ca="http://cameron.ca">

      <xs:import namespace="http://cameron.ca" schemaLocation="schema1.xsd"/>

    which somewhere does

      <xs:element name="GetFacilityInfoResult">

         <xs:complexType>

            <xs:sequence>

              <xs:element ref="ca:Facility"/>

    then you would need to change the targetNamespace of the first schema to say

      targetNamespace="http://tempuri.org"

    and of course change the import in the second schema as well

        <xs:import namespace="http://tempuri.org" schemaLocation="schema1.xsd"/>

    If the xs:import does not have a namespace attribute then it is easier, you only have to change the targetNamespace in the first schema.


    MVP Data Platform Development My blog

    • Marcado como respuesta Cameron_C martes, 13 de marzo de 2012 14:43
    domingo, 11 de marzo de 2012 11:20
  • Thanks Martin, I will try this.

    Cameron Conacher

    domingo, 11 de marzo de 2012 18:17