|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Base interface for three-part NewsML names.
Formal names are the key to NewsML's extensibility, and bear very strong similarities to XML Namespace-qualified names. Each formal name consists of three parts:
For full interoperability, applications must consider all three parts of the formal name.
Note that unlike many of the interfaces in this library, the FormalNameNode interface does not correspond to a single XML element type; instead, it is used to deliver formal-name information present in many different types of XML elements.
The vocabulary and scheme information for a formal name may
appear in the XML element itself, or it may be defaulted from
another element in the XML document or even from a separate
document. To help avoid nasty surprises (such delays or failures
retrieving large external catalogs over HTTP), this interface has
two pairs of methods for retrieving the vocabulary and scheme:
getVocabulary()
and (in the derived FormalName
and
NewsItemId
interfaces) FormalName.getScheme()
and
NewsItemId.getScheme()
retrieve only the vocabulary and
scheme explicitly provided in the XML element containing the formal
name, and thus work in constant time; getDefaultVocabulary(boolean)
and getDefaultScheme(boolean)
look for DefaultVocabularyFor
declarations in higher-level Catalog
objects within the
current document, and, if the useExternal parameter is set, in
external catalogs as well. Please note that using this option
could be extremely slow, depending on the quality of your network
connection and the availability of the server hosting the
catalog.
Method Summary | |
Topic |
findTopic(boolean useExternal)
Find the topic associated with this formal name. |
String |
getDefaultScheme(boolean useExternal)
Get an explicit or defaulted scheme. |
String |
getDefaultVocabulary(boolean useExternal)
Get an explicit or defaulted vocabulary reference. |
Text |
getName()
Get the local name. |
TopicSet |
getTopicSet(boolean useExternal)
Get the topic set for the formal name. |
Text |
getVocabulary()
Get an explicitly-specified vocabulary reference. |
String |
toString()
Generate a naive string representation of this FormalNameNode. |
String |
toString(boolean useExternal)
Generate a proper string representation of this formal name. |
Method Detail |
public Text getName()
The local name is the basic name, such as "length" or "person"; it may be qualified by a vocabulary and, optionally, a scheme. In the XML markup, the local name is usually specified by a FormalName attribute, but it occasionally appears under a different attribute name (such as "HowPresent") or even as character-data content; this interface hides the inconsistency from the user.
getVocabulary()
public Text getVocabulary()
This method returns only a vocabulary that has been explicitly provided in the XML.
getDefaultVocabulary(boolean)
public String getDefaultVocabulary(boolean useExternal) throws IOException
Get a pointer to the vocabulary for the formal name. The pointer may be a reference to an internal topic set (beginning with '#'), or it may be a URL or URN. If the vocabulary comes from a resource with a DefaultVocabularyFor declaration, then the following order of precedence applies:
An explicit Vocabulary attribute always takes precedence over a DefaultVocabularyFor declaration, however.
Note 1: the XPath for the DefaultVocabularyFor declaration will be applied using the parent of the containing Catalog as the context node (the NewsML 1.0 functional specification fails to specify any context node, so this is a best guess). According to the XPath specification, an XPath expression like "TopicType" is an abbreviation of "child::TopicType", so it will fail unless TopicType is a sibling of the Catalog. Normally, it will be best to write expressions like "descendant::TopicType" to avoid ambiguity.
Note 2: XPath expressions may match the FormalName attribute or the containing element. If an attribute other than FormalName holds the formal name (as is the case with the %assignment; attributes Importance, Confidence, and HowPresent) the XPath expression must match the attribute itself to avoid ambiguity.
useExternal
- If true, follow links outside of the current
NewsML document during catalog resolution.IOException
- If there is an error retrieving an
external resource.NewsMLException
- If there is an error retrieving an
ancestor Catalog (see Catalog.getReferencedCatalog(boolean)
).getName()
,
getVocabulary()
public String getDefaultScheme(boolean useExternal) throws IOException
See getDefaultVocabulary(boolean)
for resolution
details.
useExternal
- If true, follow links outside of the current
document for Catalog resolution.IOException
- If there is an error retrieving an
external resource.NewsMLException
- If there is an error retrieving an
ancestor Catalog (see Catalog.getReferencedCatalog(boolean)
).FormalName.getScheme()
,
NewsItemId.getScheme()
public TopicSet getTopicSet(boolean useExternal) throws IOException
This method will attempt to look up a topic set corresponding to the vocabulary.
useExternal
- If true, follow links outside of the current
document for topic set resolution.IOException
- If there is an error retrieving an
external resource.public Topic findTopic(boolean useExternal) throws IOException
Try to find a topic for this formal name, using the vocabulary to locate a TopicSet, and then the name and scheme to locate a Topic. This method will follow all TopicSetRefs within the limits of the useExternal parameter, but will fail with NewsML URNs.
useExternal
- If true, follow links outside of the current
NewsML document during topic-set reference resolution.IOException
- If there is an error retrieving
an external resource.public String toString()
The generated string will consist of the vocabulary URL in braces, followed by the scheme in braces, followed by the local name, as in
{Vocabulary}{Scheme}LocalName
If the vocabulary or scheme is absent, it will be represented by an empty pair of braces.
NOTE: to avoid problems during debugging
situations, the string will be generated only from the
information supplied explicitly in attributes; defaulted
vocabularies and schemes from DefaultVocabularyFor
declarations in Resource
objects will not be used. To
get the defaulted information in the string, use the toString(boolean)
method.
toString
in class Object
getVocabulary()
,
FormalName.getScheme()
,
NewsItemId.getScheme()
,
getName()
public String toString(boolean useExternal) throws IOException
The format is the same as that used by the zero-argument
toString()
method, but this method will look for
defaulted vocabulary and scheme information from catalogs in
the current document, and, if the useExternal flag is true,
from external documents as well.
useExternal
- If true, follow links outside of the current
NewsML document during catalog resolution.IOException
- If there is an error retrieving
an external resource.getDefaultVocabulary(boolean)
,
getDefaultScheme(boolean)
,
getName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |