Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » [FYI] More Tests with Schemas defined in WSDL
[FYI] More Tests with Schemas defined in WSDL [message #22392] Thu, 15 May 2003 23:50 Go to next message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

Ed,

I am well awaring that you are working on the schema validation
for the URI, http://www.w3.org/2001/XMLSchema.xsd, as we
discussed in the previous postings. But I had more tests against
the other schemas defined in [1]the W3C/WSDL WD v1.2.

The tested XML schemas listed under the section 1.1, "Notational
Conventions", in [1]the W3C/WSDL WD v1.2 as follows:

wsdl http://www.w3.org/2003/03/wsdl/
soap12 http://www.w3.org/2003/01/wsdl/soap12
http http://www.w3.org/2003/01/wsdl/http
mime http://www.w3.org/2003/01/wsdl/mime
xs http://www.w3.org/2001/XMLSchema
xsi http://www.w3.org/2001/XMLSchema-instance


The "wsdl" is the only one it passed and the rest of them produced
the diagnostic messages. The test was running with the code
snippet I have posted in my previous posting. If, however, you need
it again as well as diagnostic messages, pelase let me know. Thank
you.

Regards,


Pae


[1] W3C/WSDL WD(03 Mar. 2003): http://www.w3.org/TR/wsdl12/
Re: [FYI] More Tests with Schemas defined in WSDL [message #22622 is a reply to message #22392] Fri, 16 May 2003 11:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------F31AF1EC071A043BB17CB283
Content-Type: multipart/alternative;
boundary="------------10FEC6828E2629B48D00952A"


--------------10FEC6828E2629B48D00952A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Pae,

I'm updating XSDMainTest.java to support a -validate option so that I
can run tests like this to print diagnostics:

> for i in $(cat list-of-uris); do xsd-test.bat -validate $i;
echo "-----"; done
--> http://www.w3.org/2003/03/wsdl/
-----
--> http://www.w3.org/2003/01/wsdl/soap12
--> http://www.w3.org/2003/01/wsdl/wsdl12.xsd
-----
--> http://www.w3.org/2003/01/wsdl/http
Fatal: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1

DOM: The content of elements must consist of well-formed
character data or markup.
Error: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1

XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2003/01/wsdl/mime
Fatal: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1

DOM: The content of elements must consist of well-formed
character data or markup.
Error: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1

XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2001/XMLSchema
Error: URI http://www.w3.org/2001/XMLSchema Line 1 Column 1
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2001/XMLSchema-instance
Fatal: URI http://www.w3.org/2001/XMLSchema-instance Line 1
Column 1
IO:
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchema.dtd
(The system cannot find the file specified)
-----

The wsdl and soap URIs resolve and validate fine. The http and mime URIs
don't resolve to XSD content. The XMLSchema URI doesn't either, unless
you append .xsd to it. And the XMLSchema-instance resolves but the
document has a reference to XMLSchema.dtd without a public ID to help
resolve it; this schema is inherently invalid because the spec rules out
any explicit declaration of the xsi attributes.

I expect that all of the problems you are seeing are because in your
code the schema is not in a resource set which is necessary in order for
cross document references to be resolved. So I would expect that you
are seeing lots of errors about unresolved references.

I've attached updated XSDMainTest.java that will be available with the
next drop.


Pae Choi wrote:

> Ed,
>
> I am well awaring that you are working on the schema validation
> for the URI, http://www.w3.org/2001/XMLSchema.xsd, as we
> discussed in the previous postings. But I had more tests against
> the other schemas defined in [1]the W3C/WSDL WD v1.2.
>
> The tested XML schemas listed under the section 1.1, "Notational
> Conventions", in [1]the W3C/WSDL WD v1.2 as follows:
>
> wsdl http://www.w3.org/2003/03/wsdl/
> soap12 http://www.w3.org/2003/01/wsdl/soap12
> http http://www.w3.org/2003/01/wsdl/http
> mime http://www.w3.org/2003/01/wsdl/mime
> xs http://www.w3.org/2001/XMLSchema
> xsi http://www.w3.org/2001/XMLSchema-instance
>
> The "wsdl" is the only one it passed and the rest of them produced
> the diagnostic messages. The test was running with the code
> snippet I have posted in my previous posting. If, however, you need
> it again as well as diagnostic messages, pelase let me know. Thank
> you.
>
> Regards,
>
> Pae
>
> [1] W3C/WSDL WD(03 Mar. 2003): http://www.w3.org/TR/wsdl12/

--------------10FEC6828E2629B48D00952A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Pae,
<p>I'm updating XSDMainTest.java to support a <font color="#3333FF">-validate</font>
option so that I can run tests like this to print diagnostics:
<blockquote><tt><font size=-1>> for i in $(cat list-of-uris); do <font color="#3333FF">xsd-test.bat
-validate</font> $i; echo "-----"; done</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/</A></font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/wsdl/soap12</A></font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/wsdl12.xsd">http://www.w3.org/2003/01/wsdl/wsdl12.xsd</A></font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>DOM: The content of elements must consist of well-formed
character data or markup.</font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>DOM: The content of elements must consist of well-formed
character data or markup.</font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A></font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A>
Line 1 Column 1</font></tt>
<br><tt><font size=-1>IO: D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchema.dtd
(The system cannot find the file specified)</font></tt>
<br><tt><font size=-1>-----</font></tt></blockquote>
The wsdl and soap URIs resolve and validate fine. The http and mime URIs
don't resolve to XSD content.&nbsp; The XMLSchema URI doesn't either, unless
you append .xsd to it.&nbsp; And the XMLSchema-instance resolves but the
document has a reference to XMLSchema.dtd without a public ID to help resolve
it; this schema is inherently invalid because the spec rules out any explicit
declaration of the xsi attributes.
<p>I expect that all of the problems you are seeing are because in your
code the schema is not in a resource set which is necessary in order for
cross document references to be resolved.&nbsp; So I would expect that
you are seeing lots of errors about unresolved references.
<p>I've attached updated XSDMainTest.java that will be available with the
next drop.
<br>&nbsp;
<p>Pae Choi wrote:
<blockquote TYPE=CITE>Ed,
<p>I am well awaring that you are working on the schema validation
<br>for the URI, <a href="http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLSchema.xsd</a>,
as we
<br>discussed in the previous postings. But I had more tests against
<br>the other schemas defined in [1]the W3C/WSDL WD v1.2.
<p>The tested XML schemas listed under the section 1.1, "Notational
<br>Conventions", in [1]the W3C/WSDL WD v1.2 as follows:
<p> wsdl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <a href="http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/</a>
<br>soap12&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/wsdl/soap12</a>
<br> http&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</a>
<br>mime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</a>
<br> xs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>
<br> xsi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>
<p>The "wsdl" is the only one it passed and the rest of them produced
<br>the diagnostic messages. The test was running with the code
<br>snippet I have posted in my previous posting. If, however, you need
<br>it again as well as diagnostic messages, pelase let me know. Thank
<br>you.
<p>Regards,
<p>Pae
<p>[1] W3C/WSDL WD(03 Mar. 2003): <a href="http://www.w3.org/TR/wsdl12/">http://www.w3.org/TR/wsdl12/</a></blockquote>
</html>

--------------10FEC6828E2629B48D00952A--

--------------F31AF1EC071A043BB17CB283
Content-Type: text/plain; charset=us-ascii;
name="XSDMainTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="XSDMainTest.java"

/**
* <copyright>
*
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*
* </copyright>
*
* %W%
* @version %I% %H%
*/
package org.eclipse.xsd.test;


import java.io.File;

import java.util.Iterator;

import org.eclipse.core.boot.IPlatformRunnable;

import org.eclipse.emf.common.util.URI;

import org.eclipse.emf.ecore.EcorePackage;

import org.eclipse.emf.ecore.impl.EcorePackageImpl;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

import org.eclipse.xsd.XSDDiagnostic;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDPlugin;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaCompositor;
import org.eclipse.xsd.XSDSchemaDirective;

import org.eclipse.xsd.impl.XSDPackageImpl;

import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;

import org.w3c.dom.Document;
import org.w3c.dom.Element;


/**
* Supports command line invocation to drive XML Schema model tests.
* It handles both {@link #run headless} invocation and {@link #main standalone} invocation.
* <p>
* You can execute one of these test by running
*<pre>
* xsd-test.bat
*</pre>
* or
*<pre>
* xsd-standalone-test.bat
*</pre>
* from the directory:
*<pre>
* plugins/org.eclipse.xsd.test/test/
*</pre>
* </p>
* @see #run
* @see #main
*/
public class XSDMainTest // implements IPlatformRunnable
{
{
// This is needed because we can't have the following in the plugin.xml
//
// <extension point = "org.eclipse.emf.extension_parser">
// <parser type="xsd" class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a conflicting registration for this.
//
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new XSDResourceFactoryImpl());
}

public static class Runnable extends XSDMainTest implements IPlatformRunnable
{
}

/**
* Executes a stand-alone test.
* @param objects an array of Strings from the command line.
* @see #run
*/
public static void main(String args[])
{
System.exit(((Integer)new XSDMainTest().run(args)).intValue());
}

/**
* Creates an instance.
*/
public XSDMainTest()
{
}

/**
* Executes a headless workbench test.
* If no arguments are provided, the {@link XSDPrototypicalSchema} will be tested;
* otherwise each argument is taken to be the URI of a schema which will be loaded and printed.
* @param objects an array of Strings from the command line, each representing the URI of a schema.
* @return <code>0</code> indicating success, or <code>1</code> indicating failure.
* @see #main
*/
public Object run(Object object)
{
try
{
// If there are no arguments...
//
String[] arguments = (String[])object;
if (arguments.length == 0)
{
// Serialize the Purchase Order schema sample.
//
XSDPrototypicalSchema xsdPrototypicalSchema = new XSDPrototypicalSchema();
System.out.println("<!-- ** PurchaseOrderSchema ** -->");
XSDSchema xsdPurchaseOrderSchema = xsdPrototypicalSchema.getPurchaseOrderSchema();
if (xsdPurchaseOrderSchema.getElement() == null)
{
xsdPurchaseOrderSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdPurchaseOrderSchema.getElement());

// Serialize the prototypical schema sample.
//
System.out.println("<!-- ** PrototypicalSchema ** -->");
XSDSchema xsdSchema = xsdPrototypicalSchema.getPrototypicalSchema();
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
System.out.println("===== clone =====");

XSDSchema clonedSchema = (XSDSchema)xsdSchema.cloneConcreteComponent(true, true);
clonedSchema.setElement(null);
clonedSchema.updateElement();

XSDResourceImpl.serialize(System.out, clonedSchema.getElement());

System.out.println("===== clone schema for schema =====");
XSDSchema clonedSchemaForSchema = (XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true, true);
clonedSchemaForSchema.setElement(null);
clonedSchemaForSchema.updateElement();
XSDResourceImpl.serialize(System.out, clonedSchemaForSchema.getElement());
}
else if (arguments[0].equals("-printTest"))
{
XSDPrototypicalSchema xsdPrototypicalSchema = XSDPrototypicalSchema.getInstance();

// Iterate over the schema arguments.
//
for (int i = 1; i < arguments.length; ++i)
{
xsdPrototypicalSchema.printSchema(arguments[i]);
}
}
else if (arguments[0].equals("-createTest"))
{
Document document = (Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cloneNode(true);

XSDSchema xsdSchema = XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElement());
if (xsdSchema != null)
{
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
}
}
else if (arguments[0].equals("-saveTest"))
{
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1]);
}
else if (arguments[0].equals("-traceLoad"))
{
for (int i = 1; i < arguments.length; ++i)
{
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]);
}
}
else if (arguments[0].equals("-clone"))
{
XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), false));

XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), true));
}
else if (arguments[0].equals("-crossReferenceTest"))
{
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out);
}
else if (arguments[0].equals("-validate"))
{
// Iterate over the schema arguments.
//
for (int i = 1; i < arguments.length; ++i)
{
validate(arguments[i]);
}
}
else
{
// Iterate over the schema arguments.
//
for (int i = 0; i < arguments.length; ++i)
{
System.out.println("<!-- << " + arguments[i] + " >> -->");
loadAndPrint(arguments[i]);
}
}

return new Integer(0);
}
catch (Exception exception)
{
exception.printStackTrace();
return new Integer(1);
}
}

/**
* Prints a header tag for the given schema.
* @param xsdSchema a schema.
*/
protected void printSchemaStart(XSDSchema xsdSchema)
{
System.out.print("<schema targetNamespace=\"");
if (xsdSchema.getTargetNamespace() != null)
{
System.out.print(xsdSchema.getTargetNamespace());
}
System.out.print("\" schemaLocation=\"");
if (xsdSchema.getSchemaLocation() != null)
{
System.out.print(xsdSchema.getSchemaLocation());
}
System.out.print("\">");
}

/**
* Prints directive tags for those directives that reference the given schema.
* @param indent the indentation string to print at the start of each line.
* @param xsdSchema a schema.
*/
protected void printDirectives(String indent, XSDSchema xsdSchema)
{
System.out.print(indent);
printSchemaStart(xsdSchema);
System.out.println();

if (!xsdSchema.getReferencingDirectives().isEmpty())
{
System.out.println(indent + " <referencingDirectives>");
for (Iterator referencingDirectives = xsdSchema.getReferencingDirectives().iterator(); referencingDirectives.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)referencingDirectives.next();
XSDSchema referencingSchema = xsdSchemaDirective.getSchema();
System.out.print(indent + " ");
printSchemaStart(referencingSchema);
System.out.println();
System.out.print(indent + " ");
if (xsdSchemaDirective instanceof XSDImport)
{
XSDImport xsdImport = (XSDImport)xsdSchemaDirective;
System.out.print("<import namespace=\"");
if (xsdImport.getNamespace() != null)
{
System.out.print(xsdImport.getNamespace());
}
System.out.print("\" schemaLocation=\"");
}
else if (xsdSchemaDirective instanceof XSDRedefine)
{
System.out.print("<redefine schemaLocation=\"");
}
else if (xsdSchemaDirective instanceof XSDInclude)
{
System.out.print("<include schemaLocation=\"");
}
if (xsdSchemaDirective.getSchemaLocation() != null)
{
System.out.print(xsdSchemaDirective.getSchemaLocation());
}
System.out.println("\"/>");
System.out.println(indent + " </schema>");
}
System.out.println(indent + " </referencingDirectives>");
}

if (!xsdSchema.getIncorporatedVersions().isEmpty())
{
System.out.println(indent + " <incorporatedVersions>");
for (Iterator incorporatedVersions = xsdSchema.getIncorporatedVersions().iterator(); incorporatedVersions.hasNext(); )
{
XSDSchema incorporatedVersion = (XSDSchema)incorporatedVersions.next();
printDirectives(indent + " ", incorporatedVersion);
}
System.out.println(indent + " </incorporatedVersions>");
}

System.out.println(indent + "</schema>");
}

/**
* Load the XML Schema file and print information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void loadAndPrint(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file = new File(xsdFile);
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and those that have been included or imported.
//
for (Iterator resources = resourceSet.getResources().iterator(); resources.hasNext(); )
{
Object resource = resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
XSDSchema xsdSchema = xsdResource.getSchema();

System.out.println("<!-- ===== Schema Composition =====");
printDirectives(" ", xsdSchema);
System.out.println("-->");

Element element = xsdSchema.getElement();
if (element != null)
{
// Print the serialization of the model.
//
XSDResourceImpl.serialize(System.out, element);
}
}
}

// This removes the associated DOM element, creates a new associated DOM element, and then prints it.
// This is a good test for how well serialization works for a model created "bottom up".
//
XSDSchema xsdMainSchema = xsdMainResource.getSchema();
xsdMainSchema.setDocument(null);
xsdMainSchema.setElement(null);
xsdMainSchema.updateElement();
System.out.println("<!-- [ " + xsdMainSchema.getSchemaLocation() + " ] -->");
XSDResourceImpl.serialize(System.out, xsdMainSchema.getElement());
}

/**
* Load the XML Schema file and print any diagnostics information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void validate(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file = new File(xsdFile);
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION, Boolean.TRUE);
XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and those that have been included or imported.
//
for (Iterator resources = resourceSet.getResources().iterator(); resources.hasNext(); )
{
Object resource = resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;

System.err.println("--> " + xsdResource.getURI());

XSDSchema xsdSchema = xsdResource.getSchema();
xsdSchema.validate();

if (!xsdSchema.getAllDiagnostics().isEmpty())
{
for (Iterator i = xsdSchema.getAllDiagnostics().iterator(); i.hasNext(); )
{
XSDDiagnostic xsdDiagnostic = (XSDDiagnostic)i.next();

String localizedSeverity =
XSDPlugin.INSTANCE.getString("_UI_XSDDiagnosticSeverity_" + xsdDiagnostic.getSeverity());

System.err.println
(XSDPlugin.INSTANCE.getString
("_UI_DiagnosticFileLineColumn_message",
new Object []
{
localizedSeverity,
xsdDiagnostic.getLocationURI(),
new Integer(xsdDiagnostic.getLine()),
new Integer(xsdDiagnostic.getColumn())
}));

System.err.println(xsdDiagnostic.getMessage());
}
}
}
}
}
}

--------------F31AF1EC071A043BB17CB283--
Re: [FYI] More Tests with Schemas defined in WSDL [message #22808 is a reply to message #22622] Sat, 17 May 2003 02:27 Go to previous message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C31BFA.4E1181D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

You ar right about the http and mime URIs(where my head was?). I guess I =
was
watching the monitor too long during that time. :-) And thank you for =
the
updates as well as progress you made. What a progress!!!

Looking forward to seeing the next drop. And hope you have a pleasant =
weekend.
Thank you.

Regards,


Pae

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:3EC4CBAE.FBC381A6@ca.ibm.com...
Pae,=20
I'm updating XSDMainTest.java to support a -validate option so that I =
can run tests like this to print diagnostics:=20

> for i in $(cat list-of-uris); do xsd-test.bat -validate $i; echo =
"-----"; done=20
--> http://www.w3.org/2003/03/wsdl/=20
-----=20
--> http://www.w3.org/2003/01/wsdl/soap12=20
--> http://www.w3.org/2003/01/wsdl/wsdl12.xsd=20
-----=20
--> http://www.w3.org/2003/01/wsdl/http=20
Fatal: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1=20
DOM: The content of elements must consist of well-formed character =
data or markup.=20
Error: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2003/01/wsdl/mime=20
Fatal: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1=20
DOM: The content of elements must consist of well-formed character =
data or markup.=20
Error: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2001/XMLSchema=20
Error: URI http://www.w3.org/2001/XMLSchema Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2001/XMLSchema-instance=20
Fatal: URI http://www.w3.org/2001/XMLSchema-instance Line 1 Column 1 =

IO: =
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchem=
a.dtd (The system cannot find the file specified)=20
-----
The wsdl and soap URIs resolve and validate fine. The http and mime =
URIs don't resolve to XSD content. The XMLSchema URI doesn't either, =
unless you append .xsd to it. And the XMLSchema-instance resolves but =
the document has a reference to XMLSchema.dtd without a public ID to =
help resolve it; this schema is inherently invalid because the spec =
rules out any explicit declaration of the xsi attributes.=20
I expect that all of the problems you are seeing are because in your =
code the schema is not in a resource set which is necessary in order for =
cross document references to be resolved. So I would expect that you =
are seeing lots of errors about unresolved references.=20

I've attached updated XSDMainTest.java that will be available with the =
next drop.=20
=20

Pae Choi wrote:=20

Ed,=20
I am well awaring that you are working on the schema validation=20
for the URI, http://www.w3.org/2001/XMLSchema.xsd, as we=20
discussed in the previous postings. But I had more tests against=20
the other schemas defined in [1]the W3C/WSDL WD v1.2.=20

The tested XML schemas listed under the section 1.1, "Notational=20
Conventions", in [1]the W3C/WSDL WD v1.2 as follows:=20

wsdl http://www.w3.org/2003/03/wsdl/=20
soap12 http://www.w3.org/2003/01/wsdl/soap12=20
http http://www.w3.org/2003/01/wsdl/http=20
mime http://www.w3.org/2003/01/wsdl/mime=20
xs http://www.w3.org/2001/XMLSchema=20
xsi http://www.w3.org/2001/XMLSchema-instance=20

The "wsdl" is the only one it passed and the rest of them produced=20
the diagnostic messages. The test was running with the code=20
snippet I have posted in my previous posting. If, however, you need=20
it again as well as diagnostic messages, pelase let me know. Thank=20
you.=20

Regards,=20

Pae=20

[1] W3C/WSDL WD(03 Mar. 2003): http://www.w3.org/TR/wsdl12/



------------------------------------------------------------ -------------=
-----


/**
* <copyright>
*
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License =
v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*=20
* Contributors:=20
* IBM - Initial API and implementation
*
* </copyright>
*
* %W%
* @version %I% %H%
*/
package org.eclipse.xsd.test;


import java.io.File;

import java.util.Iterator;

import org.eclipse.core.boot.IPlatformRunnable;

import org.eclipse.emf.common.util.URI;

import org.eclipse.emf.ecore.EcorePackage;

import org.eclipse.emf.ecore.impl.EcorePackageImpl;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

import org.eclipse.xsd.XSDDiagnostic;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDPlugin;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaCompositor;
import org.eclipse.xsd.XSDSchemaDirective;

import org.eclipse.xsd.impl.XSDPackageImpl;

import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;

import org.w3c.dom.Document;
import org.w3c.dom.Element;


/**
* Supports command line invocation to drive XML Schema model tests.
* It handles both {@link #run headless} invocation and {@link #main =
standalone} invocation.
* <p>
* You can execute one of these test by running
*<pre>
* xsd-test.bat
*</pre>
* or
*<pre>
* xsd-standalone-test.bat
*</pre>
* from the directory:
*<pre>
* plugins/org.eclipse.xsd.test/test/
*</pre>
* </p>
* @see #run
* @see #main
*/
public class XSDMainTest // implements IPlatformRunnable=20
{
{
// This is needed because we can't have the following in the =
plugin.xml
//
// <extension point =3D "org.eclipse.emf.extension_parser">
// <parser type=3D"xsd" =
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a =
conflicting registration for this.
//
=
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", =
new XSDResourceFactoryImpl());
}

public static class Runnable extends XSDMainTest implements =
IPlatformRunnable
{
}

/**
* Executes a stand-alone test.
* @param objects an array of Strings from the command line.
* @see #run
*/
public static void main(String args[])=20
{
System.exit(((Integer)new XSDMainTest().run(args)).intValue());
}

/**
* Creates an instance.
*/
public XSDMainTest()=20
{
}

/**
* Executes a headless workbench test.
* If no arguments are provided, the {@link XSDPrototypicalSchema} =
will be tested;
* otherwise each argument is taken to be the URI of a schema which =
will be loaded and printed.
* @param objects an array of Strings from the command line, each =
representing the URI of a schema.
* @return <code>0</code> indicating success, or <code>1</code> =
indicating failure.
* @see #main
*/
public Object run(Object object)=20
{
try
{
// If there are no arguments...
//
String[] arguments =3D (String[])object;
if (arguments.length =3D=3D 0)=20
{
// Serialize the Purchase Order schema sample.
//
XSDPrototypicalSchema xsdPrototypicalSchema =3D new =
XSDPrototypicalSchema();
System.out.println("<!-- ** PurchaseOrderSchema ** -->");
XSDSchema xsdPurchaseOrderSchema =3D =
xsdPrototypicalSchema.getPurchaseOrderSchema();
if (xsdPurchaseOrderSchema.getElement() =3D=3D null)
{
xsdPurchaseOrderSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, =
xsdPurchaseOrderSchema.getElement());

// Serialize the prototypical schema sample.
//
System.out.println("<!-- ** PrototypicalSchema ** -->");
XSDSchema xsdSchema =3D =
xsdPrototypicalSchema.getPrototypicalSchema();
if (xsdSchema.getElement() =3D=3D null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
System.out.println("=3D=3D=3D=3D=3D clone =3D=3D=3D=3D=3D");

XSDSchema clonedSchema =3D =
(XSDSchema)xsdSchema.cloneConcreteComponent(true, true);
clonedSchema.setElement(null);
clonedSchema.updateElement();

XSDResourceImpl.serialize(System.out, =
clonedSchema.getElement());

System.out.println("=3D=3D=3D=3D=3D clone schema for schema =
=3D=3D=3D=3D=3D");
XSDSchema clonedSchemaForSchema =3D =
(XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true,=
true);
clonedSchemaForSchema.setElement(null);
clonedSchemaForSchema.updateElement();
XSDResourceImpl.serialize(System.out, =
clonedSchemaForSchema.getElement());
}
else if (arguments[0].equals("-printTest"))
{
XSDPrototypicalSchema xsdPrototypicalSchema =3D =
XSDPrototypicalSchema.getInstance();

// Iterate over the schema arguments.
//
for (int i =3D 1; i < arguments.length; ++i)
{
xsdPrototypicalSchema.printSchema(arguments[i]);
}
}
else if (arguments[0].equals("-createTest"))
{
Document document =3D =
(Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cl=
oneNode(true);

XSDSchema xsdSchema =3D =
XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElem=
ent());
if (xsdSchema !=3D null)
{
if (xsdSchema.getElement() =3D=3D null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, =
xsdSchema.getElement());
}
}
else if (arguments[0].equals("-saveTest"))
{
=
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1])=
;
}
else if (arguments[0].equals("-traceLoad"))
{
for (int i =3D 1; i < arguments.length; ++i)
{
=
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]);
}
}
else if (arguments[0].equals("-clone"))
{
XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), false));

XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), true));
}
else if (arguments[0].equals("-crossReferenceTest"))
{
=
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out);
}
else if (arguments[0].equals("-validate"))
{
// Iterate over the schema arguments.
//
for (int i =3D 1; i < arguments.length; ++i)
{
validate(arguments[i]);
}
}
else
{
// Iterate over the schema arguments.
//
for (int i =3D 0; i < arguments.length; ++i)
{
System.out.println("<!-- << " + arguments[i] + " >> -->");
loadAndPrint(arguments[i]);
}
}

return new Integer(0);
}
catch (Exception exception)
{
exception.printStackTrace();
return new Integer(1);
}
}

/**
* Prints a header tag for the given schema.
* @param xsdSchema a schema.
*/
protected void printSchemaStart(XSDSchema xsdSchema)
{
System.out.print("<schema targetNamespace=3D\"");
if (xsdSchema.getTargetNamespace() !=3D null)
{
System.out.print(xsdSchema.getTargetNamespace());
}
System.out.print("\" schemaLocation=3D\"");
if (xsdSchema.getSchemaLocation() !=3D null)
{
System.out.print(xsdSchema.getSchemaLocation());
}
System.out.print("\">");
}

/**
* Prints directive tags for those directives that reference the =
given schema.
* @param indent the indentation string to print at the start of =
each line.
* @param xsdSchema a schema.
*/
protected void printDirectives(String indent, XSDSchema xsdSchema)
{
System.out.print(indent);
printSchemaStart(xsdSchema);
System.out.println();

if (!xsdSchema.getReferencingDirectives().isEmpty())
{
System.out.println(indent + " <referencingDirectives>");
for (Iterator referencingDirectives =3D =
xsdSchema.getReferencingDirectives().iterator(); =
referencingDirectives.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective =3D =
(XSDSchemaDirective)referencingDirectives.next();
XSDSchema referencingSchema =3D =
xsdSchemaDirective.getSchema();
System.out.print(indent + " ");
printSchemaStart(referencingSchema);
System.out.println();
System.out.print(indent + " ");
if (xsdSchemaDirective instanceof XSDImport)
{
XSDImport xsdImport =3D (XSDImport)xsdSchemaDirective;
System.out.print("<import namespace=3D\"");
if (xsdImport.getNamespace() !=3D null)
{
System.out.print(xsdImport.getNamespace());
}
System.out.print("\" schemaLocation=3D\"");
}
else if (xsdSchemaDirective instanceof XSDRedefine)
{
System.out.print("<redefine schemaLocation=3D\"");
}
else if (xsdSchemaDirective instanceof XSDInclude)
{
System.out.print("<include schemaLocation=3D\"");
}
if (xsdSchemaDirective.getSchemaLocation() !=3D null)
{
System.out.print(xsdSchemaDirective.getSchemaLocation());
}
System.out.println("\"/>");
System.out.println(indent + " </schema>");
}
System.out.println(indent + " </referencingDirectives>");
}

if (!xsdSchema.getIncorporatedVersions().isEmpty())
{
System.out.println(indent + " <incorporatedVersions>");
for (Iterator incorporatedVersions =3D =
xsdSchema.getIncorporatedVersions().iterator(); =
incorporatedVersions.hasNext(); )
{
XSDSchema incorporatedVersion =3D =
(XSDSchema)incorporatedVersions.next();
printDirectives(indent + " ", incorporatedVersion);
}
System.out.println(indent + " </incorporatedVersions>");
}

System.out.println(indent + "</schema>");
}

/**
* Load the XML Schema file and print information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void loadAndPrint(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file =3D new File(xsdFile);
if (file.isFile())
{
uri =3D URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri =3D URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the =
main schema file into it.
//
ResourceSet resourceSet =3D new ResourceSetImpl();
XSDResourceImpl xsdMainResource =3D =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and =
those that have been included or imported.
//
for (Iterator resources =3D resourceSet.getResources().iterator(); =
resources.hasNext(); )
{
Object resource =3D resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource =3D (XSDResourceImpl)resource;
XSDSchema xsdSchema =3D xsdResource.getSchema();

System.out.println("<!-- =3D=3D=3D=3D=3D Schema Composition =
=3D=3D=3D=3D=3D");
printDirectives(" ", xsdSchema);
System.out.println("-->");

Element element =3D xsdSchema.getElement();
if (element !=3D null)
{
// Print the serialization of the model.
//
XSDResourceImpl.serialize(System.out, element);
}
}
}

// This removes the associated DOM element, creates a new =
associated DOM element, and then prints it.
// This is a good test for how well serialization works for a =
model created "bottom up".
//
XSDSchema xsdMainSchema =3D xsdMainResource.getSchema();
xsdMainSchema.setDocument(null);
xsdMainSchema.setElement(null);
xsdMainSchema.updateElement();
System.out.println("<!-- [ " + xsdMainSchema.getSchemaLocation() + =
" ] -->");
XSDResourceImpl.serialize(System.out, xsdMainSchema.getElement());
}

/**
* Load the XML Schema file and print any diagnostics information =
about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void validate(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file =3D new File(xsdFile);
if (file.isFile())
{
uri =3D URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri =3D URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the =
main schema file into it.
//
ResourceSet resourceSet =3D new ResourceSetImpl();
=
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION, =
Boolean.TRUE);
XSDResourceImpl xsdMainResource =3D =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and =
those that have been included or imported.
//
for (Iterator resources =3D resourceSet.getResources().iterator(); =
resources.hasNext(); )
{
Object resource =3D resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource =3D (XSDResourceImpl)resource;

System.err.println("--> " + xsdResource.getURI());

XSDSchema xsdSchema =3D xsdResource.getSchema();
xsdSchema.validate();

if (!xsdSchema.getAllDiagnostics().isEmpty())
{
for (Iterator i =3D =
xsdSchema.getAllDiagnostics().iterator(); i.hasNext(); )
{
XSDDiagnostic xsdDiagnostic =3D (XSDDiagnostic)i.next();
=20
String localizedSeverity =3D=20
XSDPlugin.INSTANCE.getString("_UI_XSDDiagnosticSeverity_" =
+ xsdDiagnostic.getSeverity());

System.err.println
(XSDPlugin.INSTANCE.getString
("_UI_DiagnosticFileLineColumn_message",=20
new Object []=20
{=20
localizedSeverity,=20
xsdDiagnostic.getLocationURI(),=20
new Integer(xsdDiagnostic.getLine()),=20
new Integer(xsdDiagnostic.getColumn())=20
}));

System.err.println(xsdDiagnostic.getMessage());
}
}
}
}
}
}


------=_NextPart_000_0016_01C31BFA.4E1181D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Ed,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>You ar right about the http and mime URIs(where my =
head was?).=20
I guess I was</FONT></DIV>
<DIV><FONT size=3D2>watching the monitor too long during that time. :-) =
And thank=20
you for the</FONT></DIV>
<DIV><FONT size=3D2>updates as well as progress you made. What a=20
progress!!!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Looking forward to seeing the next drop. And hope =
you have a=20
pleasant weekend.</FONT></DIV>
<DIV><FONT size=3D2>Thank you.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Regards,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Pae</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:3EC4CBAE.FBC381A6@ca.ibm.com">news:3EC4CBAE.FBC381A6@ca.ibm.=
com</A>...</DIV>Pae,=20

<P>I'm updating XSDMainTest.java to support a <FONT=20
color=3D#3333ff>-validate</FONT> option so that I can run tests like =
this to=20
print diagnostics:=20
<BLOCKQUOTE><TT><FONT size=3D-1>&gt; for i in $(cat list-of-uris); do =
<FONT=20
color=3D#3333ff>xsd-test.bat -validate</FONT> $i; echo "-----";=20
done</FONT></TT> <BR><TT><FONT size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/<=
/A></FONT></TT>=20
<BR><TT><FONT size=3D-1>-----</FONT></TT> <BR><TT><FONT =
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/=
wsdl/soap12</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/wsdl12.xsd">http://www.w3.org/2003=
/01/wsdl/wsdl12.xsd</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>-----</FONT></TT> <BR><TT><FONT =
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>DOM: The content =
of=20
elements must consist of well-formed character data or =
markup.</FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>DOM: The content =
of=20
elements must consist of well-formed character data or =
markup.</FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>IO:=20
=
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchem=
a.dtd=20
(The system cannot find the file specified)</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>-----</FONT></TT></BLOCKQUOTE>The wsdl and soap URIs =
resolve and=20
validate fine. The http and mime URIs don't resolve to XSD =
content.&nbsp; The=20
XMLSchema URI doesn't either, unless you append .xsd to it.&nbsp; And =
the=20
XMLSchema-instance resolves but the document has a reference to =
XMLSchema.dtd=20
without a public ID to help resolve it; this schema is inherently =
invalid=20
because the spec rules out any explicit declaration of the xsi =
attributes.=20
<P>I expect that all of the problems you are seeing are because in =
your code=20
the schema is not in a resource set which is necessary in order for =
cross=20
document references to be resolved.&nbsp; So I would expect that you =
are=20
seeing lots of errors about unresolved references.=20
<P>I've attached updated XSDMainTest.java that will be available with =
the next=20
drop. <BR>&nbsp;=20
<P>Pae Choi wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">Ed,=20
<P>I am well awaring that you are working on the schema validation =
<BR>for=20
the URI, <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLS=
chema.xsd</A>,=20
as we <BR>discussed in the previous postings. But I had more tests =
against=20
<BR>the other schemas defined in [1]the W3C/WSDL WD v1.2.=20
<P>The tested XML schemas listed under the section 1.1, "Notational=20
<BR>Conventions", in [1]the W3C/WSDL WD v1.2 as follows:=20
<P> wsdl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/<=
/A>=20
<BR>soap12&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/=
wsdl/soap12</A>=20
<BR> http&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
<BR>mime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
<BR> xs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp; =
<A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>=20
<BR> xsi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>=20

<P>The "wsdl" is the only one it passed and the rest of them =
produced=20
<BR>the diagnostic messages. The test was running with the code =
<BR>snippet=20
I have posted in my previous posting. If, however, you need <BR>it =
again as=20
well as diagnostic messages, pelase let me know. Thank <BR>you.=20
<P>Regards,=20
<P>Pae=20
<P>[1] W3C/WSDL WD(03 Mar. 2003): <A=20
=
href=3D"http://www.w3.org/TR/wsdl12/">http://www.w3.org/TR/wsdl12/</A></P=
></BLOCKQUOTE>
<P>
<HR>

<P></P>/**<BR>&nbsp;* &lt;copyright&gt;<BR>&nbsp;*<BR>&nbsp;* =
Copyright (c)=20
2002 IBM Corporation and others.<BR>&nbsp;* All rights =
reserved.&nbsp;&nbsp;=20
This program and the accompanying materials<BR>&nbsp;* are made =
available=20
under the terms of the Common Public License v1.0<BR>&nbsp;* which =
accompanies=20
this distribution, and is available at<BR>&nbsp;*=20
http://www.eclipse.org/legal/cpl-v10.html<BR>&nbsp;* <BR>&nbsp;* =
Contributors:=20
<BR>&nbsp;*&nbsp;&nbsp; IBM - Initial API and=20
implementation<BR>&nbsp;*<BR>&nbsp;* =
&lt;/copyright&gt;<BR>&nbsp;*<BR>&nbsp;*=20
%W%<BR>&nbsp;* @version %I% %H%<BR>&nbsp;*/<BR>package=20
org.eclipse.xsd.test;<BR><BR><BR>import java.io.File;<BR><BR>import=20
java.util.Iterator;<BR><BR>import=20
org.eclipse.core.boot.IPlatformRunnable;<BR><BR>import=20
org.eclipse.emf.common.util.URI;<BR><BR>import=20
org.eclipse.emf.ecore.EcorePackage;<BR><BR>import=20
org.eclipse.emf.ecore.impl.EcorePackageImpl;<BR><BR>import=20
org.eclipse.emf.ecore.resource.Resource;<BR>import=20
org.eclipse.emf.ecore.resource.ResourceSet;<BR><BR>import=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;<BR><BR >import=20
org.eclipse.xsd.XSDDiagnostic;<BR>import =
org.eclipse.xsd.XSDImport;<BR>import=20
org.eclipse.xsd.XSDInclude;<BR>import =
org.eclipse.xsd.XSDPackage;<BR>import=20
org.eclipse.xsd.XSDPlugin;<BR>import =
org.eclipse.xsd.XSDRedefine;<BR>import=20
org.eclipse.xsd.XSDSchema;<BR>import=20
org.eclipse.xsd.XSDSchemaCompositor;<BR>import=20
org.eclipse.xsd.XSDSchemaDirective;<BR><BR>import=20
org.eclipse.xsd.impl.XSDPackageImpl;<BR><BR>import=20
org.eclipse.xsd.util.XSDPrototypicalSchema;<BR>import=20
org.eclipse.xsd.util.XSDResourceFactoryImpl;<BR>import=20
org.eclipse.xsd.util.XSDResourceImpl;<BR><BR>import=20
org.w3c.dom.Document;<BR>import =
org.w3c.dom.Element;<BR><BR><BR>/**<BR>&nbsp;*=20
Supports command line invocation to drive XML Schema model =
tests.<BR>&nbsp;*=20
It handles both {@link #run headless} invocation and {@link #main =
standalone}=20
invocation.<BR>&nbsp;* &lt;p&gt;<BR>&nbsp;* You can execute one of =
these test=20
by running<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
xsd-test.bat<BR>&nbsp;*&lt;/pre&gt;<BR>&nbsp;*=20
or<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
xsd-standalone-test.bat<BR>&nbsp;*&lt;/pre&gt; <BR>&nbsp;* from the=20
directory:<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
plugins/org.eclipse.xsd.test/test/<BR>&nbsp;*&lt;/pre&gt; <BR>&nbsp;*=20
&lt;/p&gt;<BR>&nbsp;* @see #run<BR>&nbsp;* @see =
#main<BR>&nbsp;*/<BR>public=20
class XSDMainTest // implements IPlatformRunnable <BR>{<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; // This is needed because we can't have the =
following=20
in the plugin.xml<BR>&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;=20
//&nbsp;&nbsp; &lt;extension point =3D=20
"org.eclipse.emf.extension_parser"&gt;<BR>&nbsp;&nbsp;&nbsp;=20
//&nbsp;&nbsp;&nbsp;&nbsp; &lt;parser type=3D"xsd"=20
=
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl"/&gt; <BR>&nbsp;&nbsp=
;&nbsp;=20
//&nbsp;&nbsp; &lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel plugin, =
shipped with=20
WSAD, has a conflicting registration for this.<BR>&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp;=20
=
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", =
new=20
XSDResourceFactoryImpl());<BR>&nbsp; }<BR><BR>&nbsp; public static =
class=20
Runnable extends XSDMainTest implements IPlatformRunnable<BR>&nbsp;=20
{<BR>&nbsp; }<BR><BR>&nbsp; /**<BR>&nbsp;&nbsp; * Executes a =
stand-alone=20
test.<BR>&nbsp;&nbsp; * @param objects an array of Strings from the =
command=20
line.<BR>&nbsp;&nbsp; * @see #run<BR>&nbsp;&nbsp; */<BR>&nbsp; public =
static=20
void main(String args[]) <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
System.exit(((Integer)new =
XSDMainTest().run(args)).intValue());<BR>&nbsp;=20
}<BR><BR>&nbsp; /**<BR>&nbsp;&nbsp; * Creates an =
instance.<BR>&nbsp;&nbsp;=20
*/<BR>&nbsp; public XSDMainTest() <BR>&nbsp; {<BR>&nbsp; =
}<BR><BR>&nbsp;=20
/**<BR>&nbsp;&nbsp; * Executes a headless workbench =
test.<BR>&nbsp;&nbsp; * If=20
no arguments are provided, the {@link XSDPrototypicalSchema} will be=20
tested;<BR>&nbsp;&nbsp; * otherwise each argument is taken to be the =
URI of a=20
schema which will be loaded and printed.<BR>&nbsp;&nbsp; * @param =
objects an=20
array of Strings from the command line, each representing the URI of a =

schema.<BR>&nbsp;&nbsp; * @return &lt;code&gt;0&lt;/code&gt; =
indicating=20
success, or &lt;code&gt;1&lt;/code&gt; indicating =
failure.<BR>&nbsp;&nbsp; *=20
@see #main<BR>&nbsp;&nbsp; */<BR>&nbsp; public Object run(Object =
object)=20
<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If there are no=20
arguments...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] arguments =3D=20
(String[])object;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if =
(arguments.length =3D=3D 0)=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Serialize the =
Purchase=20
Order schema sample.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDPrototypicalSchema =

xsdPrototypicalSchema =3D new=20
XSDPrototypicalSchema();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

System.out.println("&lt;!-- ** PurchaseOrderSchema **=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDSchema=20
xsdPurchaseOrderSchema =3D=20
=
xsdPrototypicalSchema.getPurchaseOrderSchema();<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
if (xsdPurchaseOrderSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdPurchaseOrderSchema.updateElement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDResourceImpl.serialize(System.out,=20
=
xsdPurchaseOrderSchema.getElement());<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
// Serialize the prototypical schema=20
sample.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
System.out.println("&lt;!--=20
** PrototypicalSchema **=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDSchema =
xsdSchema =3D=20
=
xsdPrototypicalSchema.getPrototypicalSchema();<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
if (xsdSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdSchema.updateElement();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDResourceImpl.serialize(System.out,=20
xsdSchema.getElement());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

System.out.println("=3D=3D=3D=3D=3D clone=20
=3D=3D=3D=3D=3D");<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
XSDSchema=20
clonedSchema =3D (XSDSchema)xsdSchema.cloneConcreteComponent(true,=20
true);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
clonedSchema.setElement(null);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;=20
=
clonedSchema.updateElement();<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
=
clonedSchema.getElement());<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
System.out.println("=3D=3D=3D=3D=3D clone schema for schema=20
=3D=3D=3D=3D=3D");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
XSDSchema=20
clonedSchemaForSchema =3D=20
=
(XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true,=
=20
true);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
clonedSchemaForSchema.setElement(null);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
=
clonedSchemaForSchema.updateElement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
clonedSchemaForSchema.getElement());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-printTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDPrototypicalSchema=20
xsdPrototypicalSchema =3D=20
=
XSDPrototypicalSchema.getInstance();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
// Iterate over the schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdPrototypicalSchema.printSchema(arguments[i]);<BR>&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if =
(arguments[0].equals("-createTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Document document =3D=20
=
(Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cl=
oneNode(true);<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDSchema xsdSchema =3D=20
=
XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElem=
ent());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
if (xsdSchema !=3D null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if=20
(xsdSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
xsdSchema.updateElement();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&=
nbsp;&nbsp;=20
}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
xsdSchema.getElement());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if =
(arguments[0].equals("-saveTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1])=
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-traceLoad"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]); <BR>&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if (arguments[0].equals("-clone"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().printComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
(System.out,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nb=
sp;=20
=
XSDPrototypicalSchema.getInstance().cloneComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;=20
(XSDPrototypicalSchema.getPurchaseOrderSchema(),=20
false));<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().printComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
(System.out,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nb=
sp;=20
=
XSDPrototypicalSchema.getInstance().cloneComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;=20
(XSDPrototypicalSchema.getPurchaseOrderSchema(),=20
true));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else if=20
=
(arguments[0].equals("-crossReferenceTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out); <BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-validate"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Iterate over the =
schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
validate(arguments[i]);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Iterate over the =
schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 0; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
System.out.println("&lt;!-- &lt;&lt; " + arguments[i] + " &gt;&gt;=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
loadAndPrint(arguments[i]);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
return new Integer(0);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; =
catch=20
(Exception exception)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
exception.printStackTrace();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
new=20
Integer(1);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }<BR><BR>&nbsp;=20
/**<BR>&nbsp;&nbsp; * Prints a header tag for the given=20
schema.<BR>&nbsp;&nbsp; * @param xsdSchema a schema.<BR>&nbsp;&nbsp;=20
*/<BR>&nbsp; protected void printSchemaStart(XSDSchema =
xsdSchema)<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; System.out.print("&lt;schema=20
targetNamespace=3D\"");<BR>&nbsp;&nbsp;&nbsp; if =
(xsdSchema.getTargetNamespace()=20
!=3D null)<B
Re: [FYI] More Tests with Schemas defined in WSDL [message #571993 is a reply to message #22392] Fri, 16 May 2003 11:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33173
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------F31AF1EC071A043BB17CB283
Content-Type: multipart/alternative;
boundary="------------10FEC6828E2629B48D00952A"


--------------10FEC6828E2629B48D00952A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Pae,

I'm updating XSDMainTest.java to support a -validate option so that I
can run tests like this to print diagnostics:

> for i in $(cat list-of-uris); do xsd-test.bat -validate $i;
echo "-----"; done
--> http://www.w3.org/2003/03/wsdl/
-----
--> http://www.w3.org/2003/01/wsdl/soap12
--> http://www.w3.org/2003/01/wsdl/wsdl12.xsd
-----
--> http://www.w3.org/2003/01/wsdl/http
Fatal: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1

DOM: The content of elements must consist of well-formed
character data or markup.
Error: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1

XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2003/01/wsdl/mime
Fatal: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1

DOM: The content of elements must consist of well-formed
character data or markup.
Error: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1

XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2001/XMLSchema
Error: URI http://www.w3.org/2001/XMLSchema Line 1 Column 1
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not
permitted as constrained by 'XML Schema '; expecting schema
-----
--> http://www.w3.org/2001/XMLSchema-instance
Fatal: URI http://www.w3.org/2001/XMLSchema-instance Line 1
Column 1
IO:
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchema.dtd
(The system cannot find the file specified)
-----

The wsdl and soap URIs resolve and validate fine. The http and mime URIs
don't resolve to XSD content. The XMLSchema URI doesn't either, unless
you append .xsd to it. And the XMLSchema-instance resolves but the
document has a reference to XMLSchema.dtd without a public ID to help
resolve it; this schema is inherently invalid because the spec rules out
any explicit declaration of the xsi attributes.

I expect that all of the problems you are seeing are because in your
code the schema is not in a resource set which is necessary in order for
cross document references to be resolved. So I would expect that you
are seeing lots of errors about unresolved references.

I've attached updated XSDMainTest.java that will be available with the
next drop.


Pae Choi wrote:

> Ed,
>
> I am well awaring that you are working on the schema validation
> for the URI, http://www.w3.org/2001/XMLSchema.xsd, as we
> discussed in the previous postings. But I had more tests against
> the other schemas defined in [1]the W3C/WSDL WD v1.2.
>
> The tested XML schemas listed under the section 1.1, "Notational
> Conventions", in [1]the W3C/WSDL WD v1.2 as follows:
>
> wsdl http://www.w3.org/2003/03/wsdl/
> soap12 http://www.w3.org/2003/01/wsdl/soap12
> http http://www.w3.org/2003/01/wsdl/http
> mime http://www.w3.org/2003/01/wsdl/mime
> xs http://www.w3.org/2001/XMLSchema
> xsi http://www.w3.org/2001/XMLSchema-instance
>
> The "wsdl" is the only one it passed and the rest of them produced
> the diagnostic messages. The test was running with the code
> snippet I have posted in my previous posting. If, however, you need
> it again as well as diagnostic messages, pelase let me know. Thank
> you.
>
> Regards,
>
> Pae
>
> [1] W3C/WSDL WD(03 Mar. 2003): http://www.w3.org/TR/wsdl12/

--------------10FEC6828E2629B48D00952A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Pae,
<p>I'm updating XSDMainTest.java to support a <font color="#3333FF">-validate</font>
option so that I can run tests like this to print diagnostics:
<blockquote><tt><font size=-1>> for i in $(cat list-of-uris); do <font color="#3333FF">xsd-test.bat
-validate</font> $i; echo "-----"; done</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/</A></font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/wsdl/soap12</A></font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/wsdl12.xsd">http://www.w3.org/2003/01/wsdl/wsdl12.xsd</A></font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>DOM: The content of elements must consist of well-formed
character data or markup.</font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>DOM: The content of elements must consist of well-formed
character data or markup.</font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A></font></tt>
<br><tt><font size=-1>Error: URI <A HREF="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A> Line
1 Column 1</font></tt>
<br><tt><font size=-1>XSD: The element '<A HREF="http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#html</A>'
is not permitted as constrained by 'XML Schema '; expecting schema</font></tt>
<br><tt><font size=-1>-----</font></tt>
<br><tt><font size=-1>--> <A HREF="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A></font></tt>
<br><tt><font size=-1>Fatal: URI <A HREF="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A>
Line 1 Column 1</font></tt>
<br><tt><font size=-1>IO: D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchema.dtd
(The system cannot find the file specified)</font></tt>
<br><tt><font size=-1>-----</font></tt></blockquote>
The wsdl and soap URIs resolve and validate fine. The http and mime URIs
don't resolve to XSD content.&nbsp; The XMLSchema URI doesn't either, unless
you append .xsd to it.&nbsp; And the XMLSchema-instance resolves but the
document has a reference to XMLSchema.dtd without a public ID to help resolve
it; this schema is inherently invalid because the spec rules out any explicit
declaration of the xsi attributes.
<p>I expect that all of the problems you are seeing are because in your
code the schema is not in a resource set which is necessary in order for
cross document references to be resolved.&nbsp; So I would expect that
you are seeing lots of errors about unresolved references.
<p>I've attached updated XSDMainTest.java that will be available with the
next drop.
<br>&nbsp;
<p>Pae Choi wrote:
<blockquote TYPE=CITE>Ed,
<p>I am well awaring that you are working on the schema validation
<br>for the URI, <a href="http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLSchema.xsd</a>,
as we
<br>discussed in the previous postings. But I had more tests against
<br>the other schemas defined in [1]the W3C/WSDL WD v1.2.
<p>The tested XML schemas listed under the section 1.1, "Notational
<br>Conventions", in [1]the W3C/WSDL WD v1.2 as follows:
<p> wsdl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <a href="http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/</a>
<br>soap12&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/wsdl/soap12</a>
<br> http&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/wsdl/http</a>
<br>mime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/wsdl/mime</a>
<br> xs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>
<br> xsi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp; <a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>
<p>The "wsdl" is the only one it passed and the rest of them produced
<br>the diagnostic messages. The test was running with the code
<br>snippet I have posted in my previous posting. If, however, you need
<br>it again as well as diagnostic messages, pelase let me know. Thank
<br>you.
<p>Regards,
<p>Pae
<p>[1] W3C/WSDL WD(03 Mar. 2003): <a href="http://www.w3.org/TR/wsdl12/">http://www.w3.org/TR/wsdl12/</a></blockquote>
</html>

--------------10FEC6828E2629B48D00952A--

--------------F31AF1EC071A043BB17CB283
Content-Type: text/plain; charset=us-ascii;
name="XSDMainTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="XSDMainTest.java"

/**
* <copyright>
*
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*
* </copyright>
*
* %W%
* @version %I% %H%
*/
package org.eclipse.xsd.test;


import java.io.File;

import java.util.Iterator;

import org.eclipse.core.boot.IPlatformRunnable;

import org.eclipse.emf.common.util.URI;

import org.eclipse.emf.ecore.EcorePackage;

import org.eclipse.emf.ecore.impl.EcorePackageImpl;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

import org.eclipse.xsd.XSDDiagnostic;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDPlugin;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaCompositor;
import org.eclipse.xsd.XSDSchemaDirective;

import org.eclipse.xsd.impl.XSDPackageImpl;

import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;

import org.w3c.dom.Document;
import org.w3c.dom.Element;


/**
* Supports command line invocation to drive XML Schema model tests.
* It handles both {@link #run headless} invocation and {@link #main standalone} invocation.
* <p>
* You can execute one of these test by running
*<pre>
* xsd-test.bat
*</pre>
* or
*<pre>
* xsd-standalone-test.bat
*</pre>
* from the directory:
*<pre>
* plugins/org.eclipse.xsd.test/test/
*</pre>
* </p>
* @see #run
* @see #main
*/
public class XSDMainTest // implements IPlatformRunnable
{
{
// This is needed because we can't have the following in the plugin.xml
//
// <extension point = "org.eclipse.emf.extension_parser">
// <parser type="xsd" class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a conflicting registration for this.
//
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new XSDResourceFactoryImpl());
}

public static class Runnable extends XSDMainTest implements IPlatformRunnable
{
}

/**
* Executes a stand-alone test.
* @param objects an array of Strings from the command line.
* @see #run
*/
public static void main(String args[])
{
System.exit(((Integer)new XSDMainTest().run(args)).intValue());
}

/**
* Creates an instance.
*/
public XSDMainTest()
{
}

/**
* Executes a headless workbench test.
* If no arguments are provided, the {@link XSDPrototypicalSchema} will be tested;
* otherwise each argument is taken to be the URI of a schema which will be loaded and printed.
* @param objects an array of Strings from the command line, each representing the URI of a schema.
* @return <code>0</code> indicating success, or <code>1</code> indicating failure.
* @see #main
*/
public Object run(Object object)
{
try
{
// If there are no arguments...
//
String[] arguments = (String[])object;
if (arguments.length == 0)
{
// Serialize the Purchase Order schema sample.
//
XSDPrototypicalSchema xsdPrototypicalSchema = new XSDPrototypicalSchema();
System.out.println("<!-- ** PurchaseOrderSchema ** -->");
XSDSchema xsdPurchaseOrderSchema = xsdPrototypicalSchema.getPurchaseOrderSchema();
if (xsdPurchaseOrderSchema.getElement() == null)
{
xsdPurchaseOrderSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdPurchaseOrderSchema.getElement());

// Serialize the prototypical schema sample.
//
System.out.println("<!-- ** PrototypicalSchema ** -->");
XSDSchema xsdSchema = xsdPrototypicalSchema.getPrototypicalSchema();
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
System.out.println("===== clone =====");

XSDSchema clonedSchema = (XSDSchema)xsdSchema.cloneConcreteComponent(true, true);
clonedSchema.setElement(null);
clonedSchema.updateElement();

XSDResourceImpl.serialize(System.out, clonedSchema.getElement());

System.out.println("===== clone schema for schema =====");
XSDSchema clonedSchemaForSchema = (XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true, true);
clonedSchemaForSchema.setElement(null);
clonedSchemaForSchema.updateElement();
XSDResourceImpl.serialize(System.out, clonedSchemaForSchema.getElement());
}
else if (arguments[0].equals("-printTest"))
{
XSDPrototypicalSchema xsdPrototypicalSchema = XSDPrototypicalSchema.getInstance();

// Iterate over the schema arguments.
//
for (int i = 1; i < arguments.length; ++i)
{
xsdPrototypicalSchema.printSchema(arguments[i]);
}
}
else if (arguments[0].equals("-createTest"))
{
Document document = (Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cloneNode(true);

XSDSchema xsdSchema = XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElement());
if (xsdSchema != null)
{
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
}
}
else if (arguments[0].equals("-saveTest"))
{
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1]);
}
else if (arguments[0].equals("-traceLoad"))
{
for (int i = 1; i < arguments.length; ++i)
{
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]);
}
}
else if (arguments[0].equals("-clone"))
{
XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), false));

XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), true));
}
else if (arguments[0].equals("-crossReferenceTest"))
{
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out);
}
else if (arguments[0].equals("-validate"))
{
// Iterate over the schema arguments.
//
for (int i = 1; i < arguments.length; ++i)
{
validate(arguments[i]);
}
}
else
{
// Iterate over the schema arguments.
//
for (int i = 0; i < arguments.length; ++i)
{
System.out.println("<!-- << " + arguments[i] + " >> -->");
loadAndPrint(arguments[i]);
}
}

return new Integer(0);
}
catch (Exception exception)
{
exception.printStackTrace();
return new Integer(1);
}
}

/**
* Prints a header tag for the given schema.
* @param xsdSchema a schema.
*/
protected void printSchemaStart(XSDSchema xsdSchema)
{
System.out.print("<schema targetNamespace=\"");
if (xsdSchema.getTargetNamespace() != null)
{
System.out.print(xsdSchema.getTargetNamespace());
}
System.out.print("\" schemaLocation=\"");
if (xsdSchema.getSchemaLocation() != null)
{
System.out.print(xsdSchema.getSchemaLocation());
}
System.out.print("\">");
}

/**
* Prints directive tags for those directives that reference the given schema.
* @param indent the indentation string to print at the start of each line.
* @param xsdSchema a schema.
*/
protected void printDirectives(String indent, XSDSchema xsdSchema)
{
System.out.print(indent);
printSchemaStart(xsdSchema);
System.out.println();

if (!xsdSchema.getReferencingDirectives().isEmpty())
{
System.out.println(indent + " <referencingDirectives>");
for (Iterator referencingDirectives = xsdSchema.getReferencingDirectives().iterator(); referencingDirectives.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)referencingDirectives.next();
XSDSchema referencingSchema = xsdSchemaDirective.getSchema();
System.out.print(indent + " ");
printSchemaStart(referencingSchema);
System.out.println();
System.out.print(indent + " ");
if (xsdSchemaDirective instanceof XSDImport)
{
XSDImport xsdImport = (XSDImport)xsdSchemaDirective;
System.out.print("<import namespace=\"");
if (xsdImport.getNamespace() != null)
{
System.out.print(xsdImport.getNamespace());
}
System.out.print("\" schemaLocation=\"");
}
else if (xsdSchemaDirective instanceof XSDRedefine)
{
System.out.print("<redefine schemaLocation=\"");
}
else if (xsdSchemaDirective instanceof XSDInclude)
{
System.out.print("<include schemaLocation=\"");
}
if (xsdSchemaDirective.getSchemaLocation() != null)
{
System.out.print(xsdSchemaDirective.getSchemaLocation());
}
System.out.println("\"/>");
System.out.println(indent + " </schema>");
}
System.out.println(indent + " </referencingDirectives>");
}

if (!xsdSchema.getIncorporatedVersions().isEmpty())
{
System.out.println(indent + " <incorporatedVersions>");
for (Iterator incorporatedVersions = xsdSchema.getIncorporatedVersions().iterator(); incorporatedVersions.hasNext(); )
{
XSDSchema incorporatedVersion = (XSDSchema)incorporatedVersions.next();
printDirectives(indent + " ", incorporatedVersion);
}
System.out.println(indent + " </incorporatedVersions>");
}

System.out.println(indent + "</schema>");
}

/**
* Load the XML Schema file and print information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void loadAndPrint(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file = new File(xsdFile);
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and those that have been included or imported.
//
for (Iterator resources = resourceSet.getResources().iterator(); resources.hasNext(); )
{
Object resource = resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
XSDSchema xsdSchema = xsdResource.getSchema();

System.out.println("<!-- ===== Schema Composition =====");
printDirectives(" ", xsdSchema);
System.out.println("-->");

Element element = xsdSchema.getElement();
if (element != null)
{
// Print the serialization of the model.
//
XSDResourceImpl.serialize(System.out, element);
}
}
}

// This removes the associated DOM element, creates a new associated DOM element, and then prints it.
// This is a good test for how well serialization works for a model created "bottom up".
//
XSDSchema xsdMainSchema = xsdMainResource.getSchema();
xsdMainSchema.setDocument(null);
xsdMainSchema.setElement(null);
xsdMainSchema.updateElement();
System.out.println("<!-- [ " + xsdMainSchema.getSchemaLocation() + " ] -->");
XSDResourceImpl.serialize(System.out, xsdMainSchema.getElement());
}

/**
* Load the XML Schema file and print any diagnostics information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void validate(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file = new File(xsdFile);
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION, Boolean.TRUE);
XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and those that have been included or imported.
//
for (Iterator resources = resourceSet.getResources().iterator(); resources.hasNext(); )
{
Object resource = resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;

System.err.println("--> " + xsdResource.getURI());

XSDSchema xsdSchema = xsdResource.getSchema();
xsdSchema.validate();

if (!xsdSchema.getAllDiagnostics().isEmpty())
{
for (Iterator i = xsdSchema.getAllDiagnostics().iterator(); i.hasNext(); )
{
XSDDiagnostic xsdDiagnostic = (XSDDiagnostic)i.next();

String localizedSeverity =
XSDPlugin.INSTANCE.getString("_UI_XSDDiagnosticSeverity_" + xsdDiagnostic.getSeverity());

System.err.println
(XSDPlugin.INSTANCE.getString
("_UI_DiagnosticFileLineColumn_message",
new Object []
{
localizedSeverity,
xsdDiagnostic.getLocationURI(),
new Integer(xsdDiagnostic.getLine()),
new Integer(xsdDiagnostic.getColumn())
}));

System.err.println(xsdDiagnostic.getMessage());
}
}
}
}
}
}

--------------F31AF1EC071A043BB17CB283--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [FYI] More Tests with Schemas defined in WSDL [message #572187 is a reply to message #22622] Sat, 17 May 2003 02:27 Go to previous message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C31BFA.4E1181D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

You ar right about the http and mime URIs(where my head was?). I guess I =
was
watching the monitor too long during that time. :-) And thank you for =
the
updates as well as progress you made. What a progress!!!

Looking forward to seeing the next drop. And hope you have a pleasant =
weekend.
Thank you.

Regards,


Pae

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:3EC4CBAE.FBC381A6@ca.ibm.com...
Pae,=20
I'm updating XSDMainTest.java to support a -validate option so that I =
can run tests like this to print diagnostics:=20

> for i in $(cat list-of-uris); do xsd-test.bat -validate $i; echo =
"-----"; done=20
--> http://www.w3.org/2003/03/wsdl/=20
-----=20
--> http://www.w3.org/2003/01/wsdl/soap12=20
--> http://www.w3.org/2003/01/wsdl/wsdl12.xsd=20
-----=20
--> http://www.w3.org/2003/01/wsdl/http=20
Fatal: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1=20
DOM: The content of elements must consist of well-formed character =
data or markup.=20
Error: URI http://www.w3.org/2003/01/wsdl/http Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2003/01/wsdl/mime=20
Fatal: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1=20
DOM: The content of elements must consist of well-formed character =
data or markup.=20
Error: URI http://www.w3.org/2003/01/wsdl/mime Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2001/XMLSchema=20
Error: URI http://www.w3.org/2001/XMLSchema Line 1 Column 1=20
XSD: The element 'http://www.w3.org/1999/xhtml#html' is not =
permitted as constrained by 'XML Schema '; expecting schema=20
-----=20
--> http://www.w3.org/2001/XMLSchema-instance=20
Fatal: URI http://www.w3.org/2001/XMLSchema-instance Line 1 Column 1 =

IO: =
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchem=
a.dtd (The system cannot find the file specified)=20
-----
The wsdl and soap URIs resolve and validate fine. The http and mime =
URIs don't resolve to XSD content. The XMLSchema URI doesn't either, =
unless you append .xsd to it. And the XMLSchema-instance resolves but =
the document has a reference to XMLSchema.dtd without a public ID to =
help resolve it; this schema is inherently invalid because the spec =
rules out any explicit declaration of the xsi attributes.=20
I expect that all of the problems you are seeing are because in your =
code the schema is not in a resource set which is necessary in order for =
cross document references to be resolved. So I would expect that you =
are seeing lots of errors about unresolved references.=20

I've attached updated XSDMainTest.java that will be available with the =
next drop.=20
=20

Pae Choi wrote:=20

Ed,=20
I am well awaring that you are working on the schema validation=20
for the URI, http://www.w3.org/2001/XMLSchema.xsd, as we=20
discussed in the previous postings. But I had more tests against=20
the other schemas defined in [1]the W3C/WSDL WD v1.2.=20

The tested XML schemas listed under the section 1.1, "Notational=20
Conventions", in [1]the W3C/WSDL WD v1.2 as follows:=20

wsdl http://www.w3.org/2003/03/wsdl/=20
soap12 http://www.w3.org/2003/01/wsdl/soap12=20
http http://www.w3.org/2003/01/wsdl/http=20
mime http://www.w3.org/2003/01/wsdl/mime=20
xs http://www.w3.org/2001/XMLSchema=20
xsi http://www.w3.org/2001/XMLSchema-instance=20

The "wsdl" is the only one it passed and the rest of them produced=20
the diagnostic messages. The test was running with the code=20
snippet I have posted in my previous posting. If, however, you need=20
it again as well as diagnostic messages, pelase let me know. Thank=20
you.=20

Regards,=20

Pae=20

[1] W3C/WSDL WD(03 Mar. 2003): http://www.w3.org/TR/wsdl12/



------------------------------------------------------------ -------------=
-----


/**
* <copyright>
*
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License =
v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*=20
* Contributors:=20
* IBM - Initial API and implementation
*
* </copyright>
*
* %W%
* @version %I% %H%
*/
package org.eclipse.xsd.test;


import java.io.File;

import java.util.Iterator;

import org.eclipse.core.boot.IPlatformRunnable;

import org.eclipse.emf.common.util.URI;

import org.eclipse.emf.ecore.EcorePackage;

import org.eclipse.emf.ecore.impl.EcorePackageImpl;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

import org.eclipse.xsd.XSDDiagnostic;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDPlugin;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaCompositor;
import org.eclipse.xsd.XSDSchemaDirective;

import org.eclipse.xsd.impl.XSDPackageImpl;

import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;

import org.w3c.dom.Document;
import org.w3c.dom.Element;


/**
* Supports command line invocation to drive XML Schema model tests.
* It handles both {@link #run headless} invocation and {@link #main =
standalone} invocation.
* <p>
* You can execute one of these test by running
*<pre>
* xsd-test.bat
*</pre>
* or
*<pre>
* xsd-standalone-test.bat
*</pre>
* from the directory:
*<pre>
* plugins/org.eclipse.xsd.test/test/
*</pre>
* </p>
* @see #run
* @see #main
*/
public class XSDMainTest // implements IPlatformRunnable=20
{
{
// This is needed because we can't have the following in the =
plugin.xml
//
// <extension point =3D "org.eclipse.emf.extension_parser">
// <parser type=3D"xsd" =
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a =
conflicting registration for this.
//
=
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", =
new XSDResourceFactoryImpl());
}

public static class Runnable extends XSDMainTest implements =
IPlatformRunnable
{
}

/**
* Executes a stand-alone test.
* @param objects an array of Strings from the command line.
* @see #run
*/
public static void main(String args[])=20
{
System.exit(((Integer)new XSDMainTest().run(args)).intValue());
}

/**
* Creates an instance.
*/
public XSDMainTest()=20
{
}

/**
* Executes a headless workbench test.
* If no arguments are provided, the {@link XSDPrototypicalSchema} =
will be tested;
* otherwise each argument is taken to be the URI of a schema which =
will be loaded and printed.
* @param objects an array of Strings from the command line, each =
representing the URI of a schema.
* @return <code>0</code> indicating success, or <code>1</code> =
indicating failure.
* @see #main
*/
public Object run(Object object)=20
{
try
{
// If there are no arguments...
//
String[] arguments =3D (String[])object;
if (arguments.length =3D=3D 0)=20
{
// Serialize the Purchase Order schema sample.
//
XSDPrototypicalSchema xsdPrototypicalSchema =3D new =
XSDPrototypicalSchema();
System.out.println("<!-- ** PurchaseOrderSchema ** -->");
XSDSchema xsdPurchaseOrderSchema =3D =
xsdPrototypicalSchema.getPurchaseOrderSchema();
if (xsdPurchaseOrderSchema.getElement() =3D=3D null)
{
xsdPurchaseOrderSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, =
xsdPurchaseOrderSchema.getElement());

// Serialize the prototypical schema sample.
//
System.out.println("<!-- ** PrototypicalSchema ** -->");
XSDSchema xsdSchema =3D =
xsdPrototypicalSchema.getPrototypicalSchema();
if (xsdSchema.getElement() =3D=3D null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, xsdSchema.getElement());
System.out.println("=3D=3D=3D=3D=3D clone =3D=3D=3D=3D=3D");

XSDSchema clonedSchema =3D =
(XSDSchema)xsdSchema.cloneConcreteComponent(true, true);
clonedSchema.setElement(null);
clonedSchema.updateElement();

XSDResourceImpl.serialize(System.out, =
clonedSchema.getElement());

System.out.println("=3D=3D=3D=3D=3D clone schema for schema =
=3D=3D=3D=3D=3D");
XSDSchema clonedSchemaForSchema =3D =
(XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true,=
true);
clonedSchemaForSchema.setElement(null);
clonedSchemaForSchema.updateElement();
XSDResourceImpl.serialize(System.out, =
clonedSchemaForSchema.getElement());
}
else if (arguments[0].equals("-printTest"))
{
XSDPrototypicalSchema xsdPrototypicalSchema =3D =
XSDPrototypicalSchema.getInstance();

// Iterate over the schema arguments.
//
for (int i =3D 1; i < arguments.length; ++i)
{
xsdPrototypicalSchema.printSchema(arguments[i]);
}
}
else if (arguments[0].equals("-createTest"))
{
Document document =3D =
(Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cl=
oneNode(true);

XSDSchema xsdSchema =3D =
XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElem=
ent());
if (xsdSchema !=3D null)
{
if (xsdSchema.getElement() =3D=3D null)
{
xsdSchema.updateElement();
}
XSDResourceImpl.serialize(System.out, =
xsdSchema.getElement());
}
}
else if (arguments[0].equals("-saveTest"))
{
=
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1])=
;
}
else if (arguments[0].equals("-traceLoad"))
{
for (int i =3D 1; i < arguments.length; ++i)
{
=
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]);
}
}
else if (arguments[0].equals("-clone"))
{
XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), false));

XSDPrototypicalSchema.getInstance().printComponent
(System.out,
XSDPrototypicalSchema.getInstance().cloneComponent
(XSDPrototypicalSchema.getPurchaseOrderSchema(), true));
}
else if (arguments[0].equals("-crossReferenceTest"))
{
=
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out);
}
else if (arguments[0].equals("-validate"))
{
// Iterate over the schema arguments.
//
for (int i =3D 1; i < arguments.length; ++i)
{
validate(arguments[i]);
}
}
else
{
// Iterate over the schema arguments.
//
for (int i =3D 0; i < arguments.length; ++i)
{
System.out.println("<!-- << " + arguments[i] + " >> -->");
loadAndPrint(arguments[i]);
}
}

return new Integer(0);
}
catch (Exception exception)
{
exception.printStackTrace();
return new Integer(1);
}
}

/**
* Prints a header tag for the given schema.
* @param xsdSchema a schema.
*/
protected void printSchemaStart(XSDSchema xsdSchema)
{
System.out.print("<schema targetNamespace=3D\"");
if (xsdSchema.getTargetNamespace() !=3D null)
{
System.out.print(xsdSchema.getTargetNamespace());
}
System.out.print("\" schemaLocation=3D\"");
if (xsdSchema.getSchemaLocation() !=3D null)
{
System.out.print(xsdSchema.getSchemaLocation());
}
System.out.print("\">");
}

/**
* Prints directive tags for those directives that reference the =
given schema.
* @param indent the indentation string to print at the start of =
each line.
* @param xsdSchema a schema.
*/
protected void printDirectives(String indent, XSDSchema xsdSchema)
{
System.out.print(indent);
printSchemaStart(xsdSchema);
System.out.println();

if (!xsdSchema.getReferencingDirectives().isEmpty())
{
System.out.println(indent + " <referencingDirectives>");
for (Iterator referencingDirectives =3D =
xsdSchema.getReferencingDirectives().iterator(); =
referencingDirectives.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective =3D =
(XSDSchemaDirective)referencingDirectives.next();
XSDSchema referencingSchema =3D =
xsdSchemaDirective.getSchema();
System.out.print(indent + " ");
printSchemaStart(referencingSchema);
System.out.println();
System.out.print(indent + " ");
if (xsdSchemaDirective instanceof XSDImport)
{
XSDImport xsdImport =3D (XSDImport)xsdSchemaDirective;
System.out.print("<import namespace=3D\"");
if (xsdImport.getNamespace() !=3D null)
{
System.out.print(xsdImport.getNamespace());
}
System.out.print("\" schemaLocation=3D\"");
}
else if (xsdSchemaDirective instanceof XSDRedefine)
{
System.out.print("<redefine schemaLocation=3D\"");
}
else if (xsdSchemaDirective instanceof XSDInclude)
{
System.out.print("<include schemaLocation=3D\"");
}
if (xsdSchemaDirective.getSchemaLocation() !=3D null)
{
System.out.print(xsdSchemaDirective.getSchemaLocation());
}
System.out.println("\"/>");
System.out.println(indent + " </schema>");
}
System.out.println(indent + " </referencingDirectives>");
}

if (!xsdSchema.getIncorporatedVersions().isEmpty())
{
System.out.println(indent + " <incorporatedVersions>");
for (Iterator incorporatedVersions =3D =
xsdSchema.getIncorporatedVersions().iterator(); =
incorporatedVersions.hasNext(); )
{
XSDSchema incorporatedVersion =3D =
(XSDSchema)incorporatedVersions.next();
printDirectives(indent + " ", incorporatedVersion);
}
System.out.println(indent + " </incorporatedVersions>");
}

System.out.println(indent + "</schema>");
}

/**
* Load the XML Schema file and print information about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void loadAndPrint(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file =3D new File(xsdFile);
if (file.isFile())
{
uri =3D URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri =3D URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the =
main schema file into it.
//
ResourceSet resourceSet =3D new ResourceSetImpl();
XSDResourceImpl xsdMainResource =3D =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and =
those that have been included or imported.
//
for (Iterator resources =3D resourceSet.getResources().iterator(); =
resources.hasNext(); )
{
Object resource =3D resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource =3D (XSDResourceImpl)resource;
XSDSchema xsdSchema =3D xsdResource.getSchema();

System.out.println("<!-- =3D=3D=3D=3D=3D Schema Composition =
=3D=3D=3D=3D=3D");
printDirectives(" ", xsdSchema);
System.out.println("-->");

Element element =3D xsdSchema.getElement();
if (element !=3D null)
{
// Print the serialization of the model.
//
XSDResourceImpl.serialize(System.out, element);
}
}
}

// This removes the associated DOM element, creates a new =
associated DOM element, and then prints it.
// This is a good test for how well serialization works for a =
model created "bottom up".
//
XSDSchema xsdMainSchema =3D xsdMainResource.getSchema();
xsdMainSchema.setDocument(null);
xsdMainSchema.setElement(null);
xsdMainSchema.updateElement();
System.out.println("<!-- [ " + xsdMainSchema.getSchemaLocation() + =
" ] -->");
XSDResourceImpl.serialize(System.out, xsdMainSchema.getElement());
}

/**
* Load the XML Schema file and print any diagnostics information =
about it.
* @param xsdFile the URI of an XML Schema file.
*/
public void validate(String xsdFile) throws Exception
{
// This let's us test whether the string exists as a file.
// It not, we try as a URI.
//
URI uri;
File file =3D new File(xsdFile);
if (file.isFile())
{
uri =3D URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri =3D URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the =
main schema file into it.
//
ResourceSet resourceSet =3D new ResourceSetImpl();
=
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION, =
Boolean.TRUE);
XSDResourceImpl xsdMainResource =3D =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());

// Iterate over all the resources, i.e., the main resource and =
those that have been included or imported.
//
for (Iterator resources =3D resourceSet.getResources().iterator(); =
resources.hasNext(); )
{
Object resource =3D resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource =3D (XSDResourceImpl)resource;

System.err.println("--> " + xsdResource.getURI());

XSDSchema xsdSchema =3D xsdResource.getSchema();
xsdSchema.validate();

if (!xsdSchema.getAllDiagnostics().isEmpty())
{
for (Iterator i =3D =
xsdSchema.getAllDiagnostics().iterator(); i.hasNext(); )
{
XSDDiagnostic xsdDiagnostic =3D (XSDDiagnostic)i.next();
=20
String localizedSeverity =3D=20
XSDPlugin.INSTANCE.getString("_UI_XSDDiagnosticSeverity_" =
+ xsdDiagnostic.getSeverity());

System.err.println
(XSDPlugin.INSTANCE.getString
("_UI_DiagnosticFileLineColumn_message",=20
new Object []=20
{=20
localizedSeverity,=20
xsdDiagnostic.getLocationURI(),=20
new Integer(xsdDiagnostic.getLine()),=20
new Integer(xsdDiagnostic.getColumn())=20
}));

System.err.println(xsdDiagnostic.getMessage());
}
}
}
}
}
}


------=_NextPart_000_0016_01C31BFA.4E1181D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Ed,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>You ar right about the http and mime URIs(where my =
head was?).=20
I guess I was</FONT></DIV>
<DIV><FONT size=3D2>watching the monitor too long during that time. :-) =
And thank=20
you for the</FONT></DIV>
<DIV><FONT size=3D2>updates as well as progress you made. What a=20
progress!!!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Looking forward to seeing the next drop. And hope =
you have a=20
pleasant weekend.</FONT></DIV>
<DIV><FONT size=3D2>Thank you.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Regards,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Pae</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:3EC4CBAE.FBC381A6@ca.ibm.com">news:3EC4CBAE.FBC381A6@ca.ibm.=
com</A>...</DIV>Pae,=20

<P>I'm updating XSDMainTest.java to support a <FONT=20
color=3D#3333ff>-validate</FONT> option so that I can run tests like =
this to=20
print diagnostics:=20
<BLOCKQUOTE><TT><FONT size=3D-1>&gt; for i in $(cat list-of-uris); do =
<FONT=20
color=3D#3333ff>xsd-test.bat -validate</FONT> $i; echo "-----";=20
done</FONT></TT> <BR><TT><FONT size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/<=
/A></FONT></TT>=20
<BR><TT><FONT size=3D-1>-----</FONT></TT> <BR><TT><FONT =
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/=
wsdl/soap12</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/wsdl12.xsd">http://www.w3.org/2003=
/01/wsdl/wsdl12.xsd</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>-----</FONT></TT> <BR><TT><FONT =
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>DOM: The content =
of=20
elements must consist of well-formed character data or =
markup.</FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>DOM: The content =
of=20
elements must consist of well-formed character data or =
markup.</FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Error: URI <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>XSD: The element =
'<A=20
=
href=3D"http://www.w3.org/1999/xhtml#html">http://www.w3.org/1999/xhtml#h=
tml</A>'=20
is not permitted as constrained by 'XML Schema '; expecting=20
schema</FONT></TT> <BR><TT><FONT size=3D-1>-----</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>--&gt; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A></FONT></TT>=20
<BR><TT><FONT size=3D-1>Fatal: URI <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>=20
Line 1 Column 1</FONT></TT> <BR><TT><FONT size=3D-1>IO:=20
=
D:\sandbox\unpackage12\eclipse\plugins\org.eclipse.xsd.test\ test\XMLSchem=
a.dtd=20
(The system cannot find the file specified)</FONT></TT> =
<BR><TT><FONT=20
size=3D-1>-----</FONT></TT></BLOCKQUOTE>The wsdl and soap URIs =
resolve and=20
validate fine. The http and mime URIs don't resolve to XSD =
content.&nbsp; The=20
XMLSchema URI doesn't either, unless you append .xsd to it.&nbsp; And =
the=20
XMLSchema-instance resolves but the document has a reference to =
XMLSchema.dtd=20
without a public ID to help resolve it; this schema is inherently =
invalid=20
because the spec rules out any explicit declaration of the xsi =
attributes.=20
<P>I expect that all of the problems you are seeing are because in =
your code=20
the schema is not in a resource set which is necessary in order for =
cross=20
document references to be resolved.&nbsp; So I would expect that you =
are=20
seeing lots of errors about unresolved references.=20
<P>I've attached updated XSDMainTest.java that will be available with =
the next=20
drop. <BR>&nbsp;=20
<P>Pae Choi wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">Ed,=20
<P>I am well awaring that you are working on the schema validation =
<BR>for=20
the URI, <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLS=
chema.xsd</A>,=20
as we <BR>discussed in the previous postings. But I had more tests =
against=20
<BR>the other schemas defined in [1]the W3C/WSDL WD v1.2.=20
<P>The tested XML schemas listed under the section 1.1, "Notational=20
<BR>Conventions", in [1]the W3C/WSDL WD v1.2 as follows:=20
<P> wsdl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/03/wsdl/">http://www.w3.org/2003/03/wsdl/<=
/A>=20
<BR>soap12&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/soap12">http://www.w3.org/2003/01/=
wsdl/soap12</A>=20
<BR> http&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/http">http://www.w3.org/2003/01/ws=
dl/http</A>=20
<BR>mime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2003/01/wsdl/mime">http://www.w3.org/2003/01/ws=
dl/mime</A>=20
<BR> xs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp; =
<A=20
=
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>=20
<BR> xsi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp; <A=20
=
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>=20

<P>The "wsdl" is the only one it passed and the rest of them =
produced=20
<BR>the diagnostic messages. The test was running with the code =
<BR>snippet=20
I have posted in my previous posting. If, however, you need <BR>it =
again as=20
well as diagnostic messages, pelase let me know. Thank <BR>you.=20
<P>Regards,=20
<P>Pae=20
<P>[1] W3C/WSDL WD(03 Mar. 2003): <A=20
=
href=3D"http://www.w3.org/TR/wsdl12/">http://www.w3.org/TR/wsdl12/</A></P=
></BLOCKQUOTE>
<P>
<HR>

<P></P>/**<BR>&nbsp;* &lt;copyright&gt;<BR>&nbsp;*<BR>&nbsp;* =
Copyright (c)=20
2002 IBM Corporation and others.<BR>&nbsp;* All rights =
reserved.&nbsp;&nbsp;=20
This program and the accompanying materials<BR>&nbsp;* are made =
available=20
under the terms of the Common Public License v1.0<BR>&nbsp;* which =
accompanies=20
this distribution, and is available at<BR>&nbsp;*=20
http://www.eclipse.org/legal/cpl-v10.html<BR>&nbsp;* <BR>&nbsp;* =
Contributors:=20
<BR>&nbsp;*&nbsp;&nbsp; IBM - Initial API and=20
implementation<BR>&nbsp;*<BR>&nbsp;* =
&lt;/copyright&gt;<BR>&nbsp;*<BR>&nbsp;*=20
%W%<BR>&nbsp;* @version %I% %H%<BR>&nbsp;*/<BR>package=20
org.eclipse.xsd.test;<BR><BR><BR>import java.io.File;<BR><BR>import=20
java.util.Iterator;<BR><BR>import=20
org.eclipse.core.boot.IPlatformRunnable;<BR><BR>import=20
org.eclipse.emf.common.util.URI;<BR><BR>import=20
org.eclipse.emf.ecore.EcorePackage;<BR><BR>import=20
org.eclipse.emf.ecore.impl.EcorePackageImpl;<BR><BR>import=20
org.eclipse.emf.ecore.resource.Resource;<BR>import=20
org.eclipse.emf.ecore.resource.ResourceSet;<BR><BR>import=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;<BR><BR >import=20
org.eclipse.xsd.XSDDiagnostic;<BR>import =
org.eclipse.xsd.XSDImport;<BR>import=20
org.eclipse.xsd.XSDInclude;<BR>import =
org.eclipse.xsd.XSDPackage;<BR>import=20
org.eclipse.xsd.XSDPlugin;<BR>import =
org.eclipse.xsd.XSDRedefine;<BR>import=20
org.eclipse.xsd.XSDSchema;<BR>import=20
org.eclipse.xsd.XSDSchemaCompositor;<BR>import=20
org.eclipse.xsd.XSDSchemaDirective;<BR><BR>import=20
org.eclipse.xsd.impl.XSDPackageImpl;<BR><BR>import=20
org.eclipse.xsd.util.XSDPrototypicalSchema;<BR>import=20
org.eclipse.xsd.util.XSDResourceFactoryImpl;<BR>import=20
org.eclipse.xsd.util.XSDResourceImpl;<BR><BR>import=20
org.w3c.dom.Document;<BR>import =
org.w3c.dom.Element;<BR><BR><BR>/**<BR>&nbsp;*=20
Supports command line invocation to drive XML Schema model =
tests.<BR>&nbsp;*=20
It handles both {@link #run headless} invocation and {@link #main =
standalone}=20
invocation.<BR>&nbsp;* &lt;p&gt;<BR>&nbsp;* You can execute one of =
these test=20
by running<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
xsd-test.bat<BR>&nbsp;*&lt;/pre&gt;<BR>&nbsp;*=20
or<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
xsd-standalone-test.bat<BR>&nbsp;*&lt;/pre&gt; <BR>&nbsp;* from the=20
directory:<BR>&nbsp;*&lt;pre&gt;<BR>&nbsp;*&nbsp;=20
plugins/org.eclipse.xsd.test/test/<BR>&nbsp;*&lt;/pre&gt; <BR>&nbsp;*=20
&lt;/p&gt;<BR>&nbsp;* @see #run<BR>&nbsp;* @see =
#main<BR>&nbsp;*/<BR>public=20
class XSDMainTest // implements IPlatformRunnable <BR>{<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; // This is needed because we can't have the =
following=20
in the plugin.xml<BR>&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;=20
//&nbsp;&nbsp; &lt;extension point =3D=20
"org.eclipse.emf.extension_parser"&gt;<BR>&nbsp;&nbsp;&nbsp;=20
//&nbsp;&nbsp;&nbsp;&nbsp; &lt;parser type=3D"xsd"=20
=
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl"/&gt; <BR>&nbsp;&nbsp=
;&nbsp;=20
//&nbsp;&nbsp; &lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel plugin, =
shipped with=20
WSAD, has a conflicting registration for this.<BR>&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp;=20
=
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", =
new=20
XSDResourceFactoryImpl());<BR>&nbsp; }<BR><BR>&nbsp; public static =
class=20
Runnable extends XSDMainTest implements IPlatformRunnable<BR>&nbsp;=20
{<BR>&nbsp; }<BR><BR>&nbsp; /**<BR>&nbsp;&nbsp; * Executes a =
stand-alone=20
test.<BR>&nbsp;&nbsp; * @param objects an array of Strings from the =
command=20
line.<BR>&nbsp;&nbsp; * @see #run<BR>&nbsp;&nbsp; */<BR>&nbsp; public =
static=20
void main(String args[]) <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
System.exit(((Integer)new =
XSDMainTest().run(args)).intValue());<BR>&nbsp;=20
}<BR><BR>&nbsp; /**<BR>&nbsp;&nbsp; * Creates an =
instance.<BR>&nbsp;&nbsp;=20
*/<BR>&nbsp; public XSDMainTest() <BR>&nbsp; {<BR>&nbsp; =
}<BR><BR>&nbsp;=20
/**<BR>&nbsp;&nbsp; * Executes a headless workbench =
test.<BR>&nbsp;&nbsp; * If=20
no arguments are provided, the {@link XSDPrototypicalSchema} will be=20
tested;<BR>&nbsp;&nbsp; * otherwise each argument is taken to be the =
URI of a=20
schema which will be loaded and printed.<BR>&nbsp;&nbsp; * @param =
objects an=20
array of Strings from the command line, each representing the URI of a =

schema.<BR>&nbsp;&nbsp; * @return &lt;code&gt;0&lt;/code&gt; =
indicating=20
success, or &lt;code&gt;1&lt;/code&gt; indicating =
failure.<BR>&nbsp;&nbsp; *=20
@see #main<BR>&nbsp;&nbsp; */<BR>&nbsp; public Object run(Object =
object)=20
<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If there are no=20
arguments...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
//<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] arguments =3D=20
(String[])object;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if =
(arguments.length =3D=3D 0)=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Serialize the =
Purchase=20
Order schema sample.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDPrototypicalSchema =

xsdPrototypicalSchema =3D new=20
XSDPrototypicalSchema();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

System.out.println("&lt;!-- ** PurchaseOrderSchema **=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDSchema=20
xsdPurchaseOrderSchema =3D=20
=
xsdPrototypicalSchema.getPurchaseOrderSchema();<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
if (xsdPurchaseOrderSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdPurchaseOrderSchema.updateElement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDResourceImpl.serialize(System.out,=20
=
xsdPurchaseOrderSchema.getElement());<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
// Serialize the prototypical schema=20
sample.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
System.out.println("&lt;!--=20
** PrototypicalSchema **=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDSchema =
xsdSchema =3D=20
=
xsdPrototypicalSchema.getPrototypicalSchema();<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
if (xsdSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdSchema.updateElement();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDResourceImpl.serialize(System.out,=20
xsdSchema.getElement());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

System.out.println("=3D=3D=3D=3D=3D clone=20
=3D=3D=3D=3D=3D");<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
XSDSchema=20
clonedSchema =3D (XSDSchema)xsdSchema.cloneConcreteComponent(true,=20
true);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
clonedSchema.setElement(null);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;=20
=
clonedSchema.updateElement();<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
=
clonedSchema.getElement());<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
System.out.println("=3D=3D=3D=3D=3D clone schema for schema=20
=3D=3D=3D=3D=3D");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
XSDSchema=20
clonedSchemaForSchema =3D=20
=
(XSDSchema)clonedSchema.getSchemaForSchema().cloneConcreteCo mponent(true,=
=20
true);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
clonedSchemaForSchema.setElement(null);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
=
clonedSchemaForSchema.updateElement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
clonedSchemaForSchema.getElement());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-printTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDPrototypicalSchema=20
xsdPrototypicalSchema =3D=20
=
XSDPrototypicalSchema.getInstance();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
// Iterate over the schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
xsdPrototypicalSchema.printSchema(arguments[i]);<BR>&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if =
(arguments[0].equals("-createTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Document document =3D=20
=
(Document)XSDPrototypicalSchema.getPurchaseOrderSchema().get Document().cl=
oneNode(true);<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
XSDSchema xsdSchema =3D=20
=
XSDPrototypicalSchema.getInstance().createSchema(document.ge tDocumentElem=
ent());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
if (xsdSchema !=3D null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if=20
(xsdSchema.getElement() =3D=3D=20
null)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
xsdSchema.updateElement();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&=
nbsp;&nbsp;=20
}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
XSDResourceImpl.serialize(System.out,=20
xsdSchema.getElement());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =

}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if =
(arguments[0].equals("-saveTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().savePurchaseOrderSchema( arguments[1])=
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-traceLoad"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
XSDPrototypicalSchema.getInstance().traceLoading(arguments[i ]); <BR>&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else=20
if (arguments[0].equals("-clone"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().printComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
(System.out,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nb=
sp;=20
=
XSDPrototypicalSchema.getInstance().cloneComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;=20
(XSDPrototypicalSchema.getPurchaseOrderSchema(),=20
false));<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().printComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
(System.out,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nb=
sp;=20
=
XSDPrototypicalSchema.getInstance().cloneComponent<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;=20
(XSDPrototypicalSchema.getPurchaseOrderSchema(),=20
true));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else if=20
=
(arguments[0].equals("-crossReferenceTest"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
XSDPrototypicalSchema.getInstance().crossReferenceTest(Syste m.out); <BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if=20
(arguments[0].equals("-validate"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Iterate over the =
schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 1; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
validate(arguments[i]);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Iterate over the =
schema=20
arguments.<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (int i =3D 0; i =
&lt;=20
arguments.length; ++i)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
System.out.println("&lt;!-- &lt;&lt; " + arguments[i] + " &gt;&gt;=20
--&gt;");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
=
loadAndPrint(arguments[i]);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
return new Integer(0);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; =
catch=20
(Exception exception)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
exception.printStackTrace();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
new=20
Integer(1);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }<BR><BR>&nbsp;=20
/**<BR>&nbsp;&nbsp; * Prints a header tag for the given=20
schema.<BR>&nbsp;&nbsp; * @param xsdSchema a schema.<BR>&nbsp;&nbsp;=20
*/<BR>&nbsp; protected void printSchemaStart(XSDSchema =
xsdSchema)<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; System.out.print("&lt;schema=20
targetNamespace=3D\"");<BR>&nbsp;&nbsp;&nbsp; if =
(xsdSchema.getTargetNamespace()=20
!=3D null)<B
Previous Topic:XSDParser
Next Topic:Generated Namespace Prexfix xmlns:Q1: How come?
Goto Forum:
  


Current Time: Sun Jul 07 03:32:40 GMT 2024

Powered by FUDForum. Page generated in 0.03282 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top