jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes XML Schemas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Schemas" Watch "XML Schemas" New topic

XML Schemas

Trevor Green
Ranch Hand

Joined: May 30, 2001
Posts: 44
A few questions about XML Schemas:
1) How do you declare a schema in your xml document? (ie schema equivalent to <!DOCTYPE parent_node SYSTEM "file_name"> ) Are they always internal?
2) How do you use the <choice> element tag?

If you could help me with some of these answers, I'd be grateful.
[This message has been edited by Trevor Green (edited July 26, 2001).]
tom horwath

Joined: Jul 25, 2001
Posts: 4
Internal schema is within your xml document
<?xml version "1.0"?>
<!DOCTYPE parent_node[
External schema you make document with .dtd extension
<?xml version "1.0"?>
<!DOCTYPE parent_node SYSTEM " URL goes here "/nameoffile.dtd">
To declare a public external DTD:
<?xml version "1.0"?>
<!DOCTYPE parent_node PUBLIC"-//author goes here//DTD name of schema goes here//EN (if it is in english)//" " URL goes here "/nameoffile.dtd">

Ambrose Tati
Ranch Hand

Joined: Oct 03, 2000
Posts: 55
Hello there,
I think Tom got confused between DTDs and XML Schema.
You need something similar to this in your instance document:
For simplicity I did not use name spaces.

<?xml version="1.0"?>
<ROOT_ELEMENT xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
xsd:noNamespaceSchemaLocation="<your schema doc>">
Trevor Green
Ranch Hand

Joined: May 30, 2001
Posts: 44
Okay, I'm still slightly confused.
Tom, you said that basically, you treate schemas the same as DTDs. You save the schema as whatever.DTD and link it in with the <!DOCTYPE ...> syntax (as you would a DTD).
Ambrose, you said this wasn't correct. However, the syntax you described for namespaces, that's what you put at the top of the schema.xml document what do you put at the top of the original_document.xml to say the external ruleset I'm using is schema.xml (equivalent to <!DOCTYPE blah SYSTEM "document.DTD"> )?
Can you have external schemas?
I agree. Here's the link: http://aspose.com/file-tools
subject: XML Schemas
It's not a secret anymore!