locked
XSD XML namespace prefix problem RRS feed

  • Question

  • Hello anybody,

    One schema I'm referencing in many maps contains the following code snippet:

    <xs:attribute ref="xml:lang" use="required"/>

     

    The usage in an XML-file could look like that:

     

    <somename:comment type="explanation" xml:lang="en-us">text</somename:comment>

     

    This is only accepted in my schema if the referenced schema is imported which is done as the following:

    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" />

     

    But this import causes an error which message states something that the schmeaLocation is not referenced... Solution would be to take the schema-reference local. Also I think it's probably better to have all schemas local on my BizTalk server, so that it has not to download it each time processing files.

    I have downloaded the referenced xsd-file and included in my project. Now the (local) import would look like this:

    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="../_w3/xml.xsd" />

     

    The following code snipped could also be included into the schema attributes but it does not affect the result:

    xmlns:xml="http://www.w3.org/XML/1998/namespace"

     

    Now the problem:

    After I did all that mentioned above the schema validates just fine. But when I create an instance of this schema and validate the instance right after with the schema generated from it - it fails!

    I'm using this schema in some maps. When I'm testing the map and activate validate output schema it fails with the following error message:

    Output validation error: Das Präfix 'ns3' kann keinem Namespacenamen zugeordnet werden, der für "xml" oder "xmlns" reserviert ist.

    The case is, that it generates the prefix ns3 instead of xml for this namespace and this is not allowed by xml standarts I guess. The code snippet out of the xml-output from my map looks like the following.

    xmlns:ns3="http://www.w3.org/XML/1998/namespace"

     

    I googled a lot on this but didn't find the solution. Now, I just deactivate output validation for my map and it passed through. But does anybody have an idea how to solve this? Probably I'm not alone with this problem.

    Thanks for help, I appreciate.

    Thursday, June 24, 2010 11:09 AM

All replies

  • Hi Sammi,

    Regards of the xml namespace prefix . It is very special, and so is its namespace.

    See, http://www.w3.org/XML/1998/namespace 
    "The namespace whose name is http://www.w3.org/XML/1998/namespace is bound by definition to the prefix xml: according to Namespaces in XML (and by Namespaces in XML 1.1). Note that unlike all other XML namespaces, both the name and the prefix are specified; i.e., if you want XML 1.0 processors to recognize this namespace, you must use the reserved prefix xml:."

    Make sure you didn't create a different prefix for this namespace.

    BTW Did you try to use xs:include instruction not the xs:import?


    Leonid Ganeline [BizTalk MVP] Biztalkien blog
    Thursday, June 24, 2010 8:38 PM
    Moderator
  • Hi Leonid,

    Thanks for your response. I'm aware that the prefix must be xml für this special namespace. The thing is that BizTalk overwrites exactly this prefix with ns3, is that a bug?

    I've also tried xs:include, but then I get another error:

    The targetNamespae "http://www.w3.org/XML/1998/namespace" of included/redefined schema should be the same as the targetNamespace  "something" of the including schema.

    Well, of course the targetNamespaces are different, or do I need to change this?

    Or is there maybe a possibility to tell the BizTalk that he may not generate those prefixes?

    Thanks for help,

    Sam

    Friday, June 25, 2010 6:52 AM