001: package com.sun.xml.xsom.parser;
002:
003: import com.sun.xml.xsom.XSSchema;
004:
005: import java.util.Set;
006:
007: /**
008: * Represents a parsed XML schema document.
009: *
010: * <p>
011: * Unlike schema components defined in <tt>XS****</tt> interfaces,
012: * which are inherently de-coupled from where it was loaded from,
013: * {@link SchemaDocument} represents a single XML infoset that
014: * is a schema document.
015: *
016: * <p>
017: * This concept is often useful in tracking down the reference
018: * relationship among schema documents.
019: *
020: * @see XSOMParser#getDocuments()
021: * @author Kohsuke Kawaguchi
022: */
023: public interface SchemaDocument {
024: /**
025: * Gets the system ID of the schema document.
026: *
027: * @return
028: * null if {@link XSOMParser} was not given the system Id.
029: */
030: String getSystemId();
031:
032: /**
033: * The namespace that this schema defines.
034: *
035: * <p>
036: * More precisely, this method simply returns the <tt>targetNamespace</tt> attribute
037: * of the schema document. When schemas are referenced in certain ways
038: * (AKA chameleon schema), schema components in this schema document
039: * may end up defining components in other namespaces.
040: *
041: * @return
042: * can be "" but never null.
043: */
044: String getTargetNamespace();
045:
046: /**
047: * Gets {@link XSSchema} component that contains all the schema
048: * components defined in this namespace.
049: *
050: * <p>
051: * The returned {@link XSSchema} contains not just components
052: * defined in this {@link SchemaDocument} but all the other components
053: * defined in all the schemas that collectively define this namespace.
054: *
055: * @return
056: * never null.
057: */
058: XSSchema getSchema();
059:
060: /**
061: * Set of {@link SchemaDocument}s that are included/imported from this document.
062: *
063: * @return
064: * can be empty but never null. read-only.
065: */
066: Set<SchemaDocument> getReferencedDocuments();
067:
068: /**
069: * Gets the {@link SchemaDocument}s that are included from this document.
070: *
071: * @return
072: * can be empty but never null. read-only.
073: * this set is always a subset of {@link #getReferencedDocuments()}.
074: */
075: Set<SchemaDocument> getIncludedDocuments();
076:
077: /**
078: * Gets the {@link SchemaDocument}s that are imported from this document.
079: *
080: * @param targetNamespace
081: * The namespace URI of the import that you want to
082: * get {@link SchemaDocument}s for.
083: * @return
084: * can be empty but never null. read-only.
085: * this set is always a subset of {@link #getReferencedDocuments()}.
086: */
087: Set<SchemaDocument> getImportedDocuments(String targetNamespace);
088:
089: /**
090: * Returns true if this document includes the given document.
091: *
092: * <p>
093: * Note that this method returns false if this document
094: * imports the given document.
095: */
096: boolean includes(SchemaDocument doc);
097:
098: /**
099: * Returns true if this document imports the given document.
100: *
101: * <p>
102: * Note that this method returns false if this document
103: * includes the given document.
104: */
105: boolean imports(SchemaDocument doc);
106:
107: /**
108: * Set of {@link SchemaDocument}s that include/import this document.
109: *
110: * <p>
111: * This works as the opposite of {@link #getReferencedDocuments()}.
112: *
113: * @return
114: * can be empty but never null. read-only.
115: */
116: Set<SchemaDocument> getReferers();
117: }
|