XML Schema Tools: Retrieving and Referencing External XML Resources
Last Updated: 20 October 2006
Back to Getting Started With XML Schema Tools
The goal of this tutorial is to retrieve external schema files into mySchemaPrj project. The XML retrieval of resources retrieves both XML schema and WSDL (Web Services Description Language) documents. The wizard verifies that the transitive closure is satisfied, including XML schema embedded in WSDL.
The IDE will retrieve the closure of the resources when you retrieve resources from a URL.
Note: Wherever you see the
icon, you can click to view a detailed interactive demonstration of the steps described in the tutorial.
top
Retrieving XML Resources
After you use the instructions in this procedure to retrieve XML resources, you will reference those resources in the next part, Referencing External Schemas.
To retrieve XML resources:
- If mySchemaPrj is not open in the IDE, open it now.
- If the Output window is not visible, choose Window > Output.
When the IDE retrieves the resources, informational messages appear in the Output window.
- In the Projects window, expand the mySchemaPrj project node and expand the Source Packages node.
- Select the <default package> node, right-click and choose New > File/Folder.
- In the New File dialog box, under Categories, select the XML node, and in the File Types list, select External XML Schema Document(s).
- Click Next.
The New Retrieve Documents page opens.
- In the Specify Resource Location page, select the source from which to retrieve the file.
- To retrieve the resources from a URL:
- Select the From URL radio button.
- In the text field below the From URL radio button, type http://docs.oasis-open.org/ubl/cd-UBL-1.0/xsd/maindoc/UBL-Order-1.0.xsd
In this example, we are retrieving the UBL sample schema, included with Java WSDP Version 2.0, directly from a URL instead of using a local installation.
- Accept the default value for the Save to Folder field, path-to-project\mySchemaPrj\src.
- Click Finish.
Notice the information that appears in the Output window. The IDE shows which files are being copied to project folders and if there are any errors, they appear in the Output window.
The Source Packages node of your project now has three additional nodes: docs.oasis-open.org.ubl.cd-UBL-1.0.xsd.codelist, docs.oasis-open.org.ubl.cd-UBL-1.0.xsd.common, and docs.oasis-open.org.ubl.cd-UBL-1.0.xsd.maindoc.
View Demo
- To retrieve the resources from your local file system:
- Select the From Local File System radio button.
- Click the Browse button next to the text field below the From Local File System radio button.
- In the Open dialog box, navigate to and select the folder that contains the schema you want to retrieve.
In this example, we are retrieving a sample schema that is included with Java WSDP Version 2.0. The schema file resides in this folder:
jwsdp-installation-folder\jwsdp-2.0\jaxb\samples\ubl\cd-UBL-1.0\.
- Accept the default value for the Save to Folder field, path-to-project\mySchemaPrj\src.
- Click Finish.
Notice the information that appears in the Output window. The IDE shows which files are being copied to project folders and if there are any errors, they appear in the Output window.
The Source Packages node of your project now has three additional nodes: xsd.codelist, xsd.common, and xsd.maindoc.
View Demo
Expand the nodes to see information about the schema file that you retrieved into your project. The following illustration shows the expanded nodes for resources retrieved from the locally installed UBL sample schema.

top
Referencing External Schemas
In this procedure, you will add an XML schema file to your project and then reference the schema files you retrieved in the previous part.
To add a new XML schema file to the mySchemaPrj project:
- In the Projects window, expand the mySchemaPrj node and expand the Source Packages node.
- Select the <default package> node, right-click and choose New > File/Folder.
The New File wizard opens.
- In the Categories list, select XML and in the File Types list, select XML Schema.
- Click Next.
The Name and Location page of the wizard opens.
- In the Name and Location page of the wizard, make sure the File Name is newXmlSchema, accept the other default values, and click Finish.
Note: If the name of the file does not default to newXmlSchema, change it to newXmlSchema to match the instructions in this document.
The IDE opens a new tab for the newXmlSchema file with the Schema view open.
View Demo
To add an external reference:
- In the column view of the Schema view of the newXmlSchema.xsd file, select the root node (http://xml.netbeans.org/schema/newXMLSchema), right-click and choose Add > Import.
The Import dialog box opens.
- In the Location list, select the schema file.
- To select a schema file from resources retrieved from a URL:
- Expand the By File > mySchemaPrj > src > docs.oasis-open.org > ubl > cd-UBL-1.0 > xsd > maindoc nodes.
- Select UBL-Order-1.0.xsd.
The Namespace field below the Location list is filled in by the IDE, and contains the following value: urn:oasis:names:specification:ubl:schema:xsd:Order-1.0.
- In the New Prefix field, type myRef and click OK.
The IDE adds the import to your schema file.
View Demo
- To select a schema file from resources retrieved from the locally installed sample:
- Expand the By File > mySchemaPrj > src > xsd > maindoc nodes.
- Select UBL-Order-1.0.xsd.
The Namespace field below the Location list is filled in by the IDE, and contains the following value: urn:oasis:names:tc:ubl:Order:1:0.
- In the New Prefix field, type myRef.
- Click OK.
The IDE adds the import to your schema file.
View Demo
- In the first column of the Schema view, select the Referenced Schemas node.
The IDE shows the new import node in the second column of the view. If you retrieved resources from the locally installed sample, the import node should look similar to the one shown below.

- In the second column of the Schema view, select the import node, right-click and choose Go To > Source.
The IDE replaces the Schema view with the Source view. Notice that the IDE has updated the schema component to include a xmlns attribute for the schema you referenced and the prefix you defined.
- Close the Output window by clicking the close button in the window's title bar.
- From the IDE main menu, choose Window > Close All Documents.
- When the IDE prompts you to save your changes, click Save.
- In the Projects window, right-click the mySchemaPrj node and choose Close Project.
top
Next Step
The steps in Populating XML Schemas Using the Design View show you how to use the Design view in the XML schema editor to populate and modify XML schema files.
top