AW: Proper XML schema for XML files only using a default namespace

Manfred Sturm <[email protected]> Tue, 28 Jan 2003 09:40:39 +0100
Newsgroups gmane.comp.java.sun.xml.general
Message-ID <[email protected]>
Larry,

Thanks for your thoughts. Sounds very clear and obvious to me.

But the main goal of my contribution to this mailing list was to find out,
if there is a way to define a working XML Schema without having to modify
the original Visio XML file, which was:

    <?xml version="1.0" encoding="UTF-8"?>
    <VisioDocument xmlns="schemas-microsoft-com:office:visio">
        ...
    </VisioDocument>

According your analogy to package names, there isn't! Shame on Micorsoft :-(

Using explicit namespaces like:

    <?xml version="1.0" encoding="UTF-8"?>
    <visio:VisioDocument xmlns:visio="schemas-microsoft-com:office:visio">
        ...
    </visio:VisioDocument>

would help as well. Agree? But as well I need to make modifications to the
original Visio XML file :-(

Thanks anyway
Manfred

    | -----Ursprungliche Nachricht-----
    | Von: XML technologies in the Java Platform
    | [mailto:[email protected]]Im Auftrag von Larry E. Kim
    | Gesendet: Friday, January 24, 2003 5:00 PM
    | An: [email protected]
    | Betreff: Re: [XML-INTEREST] Proper XML schema for XML files
    | only using a
    | default namespace
    |
    |
    | Manfred,
    |
    | Thanks for your interest in XMLSPY.  I think you've got a namespace
    | problem. Essentially namespaces are similar to java packages,
    | it's a way
    | to avoid XML naming colisions. Your instance document declares a
    | namespace, yet the XML Schema does not declare a target namespace.
    |
    | In java-speak, a similar, (yet not exact) analogy would be as if you
    | defined a class file with no package name, then tried to create an
    | object belonging to that class, but added a package name to
    | the object.
    | Of course you'll get an error from the java compiler saying it cant
    | resolve the class.
    |
    | Try using the following code instead which uses the default
    | namepace as
    | the target namespace for the XML Schema:
    |
    |
    | <?xml version="1.0" encoding="UTF-8"?>
    | <!--W3C Schema generated by XMLSPY v5 rel. 3 U
    | (http://www.xmlspy.com)-->
    | <xs:schema targetNamespace="schemas-microsoft-com:office:visio"
    | xmlns="schemas-microsoft-com:office:visio"
    | xmlns:xs="http://www.w3.org/2001/XMLSchema"
    | elementFormDefault="qualified" attributeFormDefault="unqualified">
    |         <xs:element name="VisioDocument">
    |                 <xs:complexType>
    |                         <xs:simpleContent>
    |                                 <xs:extension base="xs:string"/>
    |                         </xs:simpleContent>
    |                 </xs:complexType>
    |         </xs:element>
    | </xs:schema>
    |
    |
    |
    | <?xml version="1.0" encoding="UTF-8"?>
    | <VisioDocument xmlns="schemas-microsoft-com:office:visio"
    | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    | xsi:schemaLocation="schemas-microsoft-com:office:visio
    | C:\PROGRA~1\Altova\XMLSPY\Examples\visio.xsd">
    | </VisioDocument>
    |
    |
    | Of course, this brings up an intersting point - that the XMLSPY Schema
    | Generator should infer target namespaces based on any namespaces
    | introduced in the instance document...
    |
    | Hope this helps.
    | -larry
    |
    |
    | ... Larry E. Kim
    | ... Marketing Director
    | ... Altova, Inc. - markup your mind!
    |
    | ===================================================================
    | The new ALTOVA product-line: xmlspy 5 - stylevision 5 - authentic 5
    | Award-winning tools for developers - web designers - business-users
    | NEW in version 5:  XSLT Debugger, WSDL Editor, HTML->XML Migration,
    | Java/C++ Code Generation,  Tamino Integration, CMS 2002 Integration
    | Visit  www.altova.com  to download your free evaluation copy today!
    | ===================================================================
    |
    | The information transmitted in this message and/or as an attachment
    | to it  is intended  only for the  person or  entity to  which it is
    | addressed and may contain confidential  and/or privileged material.
    | Any  review,  retransmission,  dissemination  or  other use of,  or
    | taking of any action in reliance upon,  this information by persons
    | or entities other than the intended recipient is prohibited. If you
    | received this in error,  please contact  the sender  and delete the
    | material from any computer.  Altova GmbH  and  Altova, Inc.  do not
    | accept legal responsibility  for the contents of this message.  Any
    | views or opinions  presented are solely  those of the author and do
    | not  necessarily  represent those of  Altova GmbH and  Altova, Inc.
    | unless otherwise specifically stated. Thank you!
    |
    |
    | -----Original Message-----
    | From: Manfred Sturm [mailto:[email protected]]
    | Sent: Thursday, January 23, 2003 3:28 AM
    | To: [email protected]
    | Subject: Proper XML schema for XML files only using a default
    | namespace
    |
    |
    | Hi
    |
    | I'm struggling in defining a proper XML schema for following XML file:
    |
    | <?xml version="1.0" encoding="UTF-8"?>
    | <VisioDocument xmlns="urn:schemas-microsoft-com:office:visio">
    | </VisioDocument>
    |
    | E.g. XMLSpy suggests the XML schema:
    |
    | <?xml version="1.0" encoding="UTF-8"?>
    | <!--W3C Schema generated by XMLSPY v5 U (http://www.xmlspy.com)-->
    | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    | elementFormDefault="qualified">  <xs:element name="VisioDocument">
    |   <xs:complexType>
    |    <xs:simpleContent>
    |     <xs:extension base="xs:string"/>
    |    </xs:simpleContent>
    |   </xs:complexType>
    |  </xs:element>
    | </xs:schema>
    |
    | Validation of the XML file returns the error:
    | "Root element of document 'vd.xml' is not defined in schema
    | document or
    | part of wrong namespace"
    |
    | I guess the second assumption is correct, but is there
    | somebody to make
    | a better job than XMLSpy?
    |
    | Thanx
    | Manfred
    |
    | -----------------------------------------------------
    | xml-interest: A list for discussing XML technologies in the Java
    | Platform. To post, mailto:[email protected] Archives at:
    | http://archives.java.sun.com/xml-interest.html
    | To unsubscribe, mailto:[email protected] the following message;
    | signoff xml-interest.
    |
    | -----------------------------------------------------
    | xml-interest: A list for discussing XML technologies in the
    | Java Platform.
    | To post, mailto:[email protected]
    | Archives at: http://archives.java.sun.com/xml-interest.html
    | To unsubscribe, mailto:[email protected] the following message;
    | signoff xml-interest.
    |

-----------------------------------------------------
xml-interest: A list for discussing XML technologies in the Java Platform.
To post, mailto:[email protected]
Archives at: http://archives.java.sun.com/xml-interest.html
To unsubscribe, mailto:[email protected] the following message;
signoff xml-interest.