Jump to content

References across namespaces

Recommended Posts

I have a first schema with a unique targetNamespace, a default namespace that of "http://www.w3.org/2001/XMLSchema",'>http://www.w3.org/2001/XMLSchema", and a global element "<element name="X"/>".The purpose of the first schema is simply to define some base element types. It's imported by a bunch of other schemas.I have a second schema, it too has a unique targetNamespace and a default namespace of "http://www.w3.org/2001/XMLSchema" that imports the first and its namespace. I also have a prefix qualified with the first schema's targetNamespace. Within the second, I reference X "<element ref="first:X"/>".The purpose of the second is to define types that are much more specific to a job. It too is imported by a bunch of schemas that are like the third described below.I have a third schema, which does this all again, and my xml file is validated against this. The purpose of this third is to describe elements specific to the xml file and more importantly the STRUCTURE of the root element of the xml file.I didn't choose this hierarchy, thats how it is in the production code.My problem is that the second element gets the error message about the first: "Message: Element must have a name or a ref attribute - element ignored". Did I qualify the reference wrong? Can anyone see the problem with my logic? Here are the example files:Three.xml--<?xml version="1.0" encoding="UTF-8"?><Three_Root xmlns="http://www.company.com/Three.xsd"targetNamespace="http://www.company.com/Three.xsd"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.company.com/Three.xsd Three.xsd"> <X>7</X></Three_Root>Three.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:Three_ns="http://www.company.com/Three.xsd"xmlns:Two_ns="http://www.company.com/Two.xsd"targetNamespace="http://www.company.com/Three.xsd"> <import schemaLocation="Two.xsd" namespace="http://www.company.com/Two.xsd"/> <element name="Three_Root"> <complexType> <sequence> <element ref="Two_ns:X"/> </sequence> </complexType> </element></schema>Two.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:Two_ns="http://www.company.com/Two.xsd"xmlns:One_ns="http://www.company.com/One.xsd"targetNamespace="http://www.company.com/Two.xsd"> <import schemaLocation="One.xsd" namespace="http://www.company.com/One.xsd"/> <element ref="One_ns:X"/></schema>One.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:One_ns="http://www.company.com/One.xsd"targetNamespace="http://www.company.com/One.xsd"> <element name="X" type="integer"/></schema>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...