1

I'm looking for validate an XML document with xrm prefix as you can read here :

I wrote the following XML Schema :

     </xsd:extension>

  </xsd:complexContent>

</xsd:complexType>


</xsd:schema>

However, when I check my XML document, I get the following error:

'xrm:plugin' is not a valid value for 'NCName'

I understand I can't put xrm: in my name, but how can I validate my xrm:plugin and xrm:header ? Because, if I try to validate my XML document, I get this error:

Cannot find the declaration of element 'xrm:plugin'.

Jonor
  • 1,102
  • 2
  • 15
  • 31

1 Answers1

1

xrm is a namespace prefix, an abbreviation for the namespace. As the syntax error indicates, a namespace prefix is not declared via xsd:element/@name. Instead, declare only the local name (plugin) and handle the namespace prefix declaration at the XSD level...

Here is a simplified set of your XML and XSD where the XML validates successfully against the XSD:

XML

<?xml version="1.0" encoding="UTF-8"?>
<xrm:plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.moss.fr/2011/connecteur_xrm result.xsd"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm">
  <xrm:header>
    <xrm:tracabilite>
      <xrm:reference_moss>MPD_4.1.1.0</xrm:reference_moss>
      <xrm:document_lie> </xrm:document_lie>
      <xrm:document_interface>SC-DIF-OT3402-0002-MOSS 1.8 - DIF COSCA Inc.2.doc</xrm:document_interface>
      <xrm:intervention>
        <xrm:auteur>Générateur de mapping v1.0</xrm:auteur>
        <xrm:date>14/01/2013</xrm:date>
        <xrm:commentaire>Génération du fichier de mapping</xrm:commentaire>
      </xrm:intervention>
    </xrm:tracabilite>
  </xrm:header>
</xrm:plugin>

XSD

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm"
            xmlns:SCCOAMCD="urn:SCCOA-schemaInfo"
            xmlns:SBEGestionZonesAeriennesSYSCA="urn:SBEGestionZonesAeriennesSYSCA-schema"
            SCCOAMCD:desc="  implémentation du MCD pivot du SCCOA 3.2.1ec  production par SCCOA mcd2mpd 4.1.1, le 11/12/2007  règles spécifiques production schémas 1.2  diagramme : A-SC.SBE GestionZonesAeriennes SYSCA  entité racine      : A-SC.ZoneAerienne "
            attributeFormDefault="unqualified"
            elementFormDefault="qualified"
            targetNamespace="http://www.moss.fr/2011/connecteur_xrm"
            version="3.2.1ec">
  <xsd:complexType name="header">
    <xsd:sequence>
      <xsd:any minOccurs="1" processContents="lax"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="plugin">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="header" type="xrm:header"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Thank you for your answer. I'm not sure to get it. I import to my schema `` and i add `xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm"` without success. I have troubles to understand because i just want to check for the prefix of my XML document, not really create another XSD with `xrm` prefix. – Jonor Jul 09 '18 at 13:54
  • I've updated the answer with a simplified set of your XML and XSD where the XML validates successfully against the XSD. – kjhughes Jul 09 '18 at 14:54
  • I'm sorry but i have always the same error : `cannot find the declaration of element 'xrm:plugin'`. I don't know if it is EditiX the problem... – Jonor Jul 09 '18 at 16:50
  • 1
    You might try specifying an absolute rather than a relative URI for the XSD in `xsi:schemaLocation="http://www.moss.fr/2011/connecteur_xrm result.xsd"`. See [**How to referene a local XML Schema file correctly?**](https://stackoverflow.com/q/19253402/290085) The above XML/XSD validated successfully using a Xerces-based validating parser with the XSD and XML document in the same directory. – kjhughes Jul 09 '18 at 17:04
  • Thanks for your help. I will try tomorrow. – Jonor Jul 09 '18 at 21:09
  • It works. But changing my xsd's targetNamespace creates new errors. I edited my post showing `base="SBEGestionZonesAeriennesSYSCA:Etat"` which was expected in the last nameSpace... I didn't thought the solution was changing nameSpace and it is why i didn't put the `xrm:mapping` in my XML document (thinking i will just repeat the modification to it). – Jonor Jul 10 '18 at 09:38
  • The target namespace of the XSD must match the namespace of the XML. Other namespaces can be used in the XML via `xsd:import` in the XSD. The above pair demonstrate several concepts needed to coordinate namespaces, and the XML validates successfully against the XSD. If these do not serve to solve all of your problems, please post a new question focused upon the new problem(s). Thank you. – kjhughes Jul 10 '18 at 12:39