Package org.apache.xmlbeans
Class XmlDocumentProperties
java.lang.Object
org.apache.xmlbeans.XmlDocumentProperties
public abstract class XmlDocumentProperties extends Object
This class is used to attach arbitrary information to an XML
document. It also defines several well-known types of
information that can be attached or found on a document.
For example, suppose you wanted to associate a filename with the document containing an xml object "xobj". This could be done via the following code:
tokenSource.documentProperties().set(XmlDocumentProperties.NAME, "MyFilename.xml");
To fetch the filename later, given an xobj2 anywhere in the same document, you can write:
filename = (String)tokenSource.documentProperties().get(XmlDocumentProperties.NAME);
-
Field Summary
Fields Modifier and Type Field Description static Object
DOCTYPE_NAME
Doc type namestatic Object
DOCTYPE_PUBLIC_ID
Doc type public idstatic Object
DOCTYPE_SYSTEM_ID
Doc type system idstatic Object
ENCODING
Document encodingstatic Object
MESSAGE_DIGEST
SHA message digeststatic Object
SOURCE_NAME
Used to store the original name (a String) for the source from which the XML document was loaded.static Object
STANDALONE
Document standlonestatic Object
VERSION
Document version -
Constructor Summary
Constructors Constructor Description XmlDocumentProperties()
-
Method Summary
Modifier and Type Method Description abstract Object
get(Object key)
Returns a value previously attached to a document using set.String
getDoctypeName()
Returns the DOCTYPE name used in the <!DOCTYPE> declaration.String
getDoctypePublicId()
Returns the DOCTYPE public ID used in the <!DOCTYPE> declaration.String
getDoctypeSystemId()
Returns the DOCTYPE system ID used in the <!DOCTYPE> declaration.String
getEncoding()
Returns the encoding used for the XML document, as an ISO encoding name.byte[]
getMessageDigest()
Returns the message digest used to summarize the document.String
getSourceName()
Returns the name of the XML document file.boolean
getStandalone()
Returns the standalone propertyString
getVersion()
Returns the XML version string used in the <?xml?> declaration.abstract Object
put(Object key, Object value)
Attaches a value to the root of the document containing the given token source.abstract Object
remove(Object key)
Removes a value previously attached to a document using set.void
setDoctypeName(String doctypename)
Sets the DOCTYPE name use in the <!DOCTYPE> declaration.void
setDoctypePublicId(String publicid)
Sets the DOCTYPE public ID to use in the <!DOCTYPE> declaration.void
setDoctypeSystemId(String systemid)
Sets the DOCTYPE system ID to use in the <!DOCTYPE> declaration.void
setEncoding(String encoding)
Sets the encoding to use for the XML document.void
setMessageDigest(byte[] digest)
Sets the message digest used to summarize the document.void
setSourceName(String sourceName)
Sets the name of the XML document file.void
setStandalone(boolean standalone)
Sets the standalone property.void
setVersion(String version)
Sets the XML version string to use in the <?xml?> declaration.
-
Field Details
-
SOURCE_NAME
Used to store the original name (a String) for the source from which the XML document was loaded. This name, if present, is used to identify the document when reporting validation or comilation errors. XmlObject.Factory.parse(File) and SchemaTypeLoader.loadInstance(File) both automatically set this value to the filename. -
ENCODING
Document encoding -
VERSION
Document version -
STANDALONE
Document standlone -
DOCTYPE_NAME
Doc type name -
DOCTYPE_PUBLIC_ID
Doc type public id -
DOCTYPE_SYSTEM_ID
Doc type system id -
MESSAGE_DIGEST
SHA message digest
-
-
Constructor Details
-
XmlDocumentProperties
public XmlDocumentProperties()
-
-
Method Details
-
setSourceName
Sets the name of the XML document file. Typically a URL, but may be any String.- Parameters:
sourceName
- the name to set- See Also:
XmlOptions.setDocumentSourceName(java.lang.String)
-
getSourceName
Returns the name of the XML document file. Typically a URL, but may be any String. -
setEncoding
Sets the encoding to use for the XML document. Should be a valid XML encoding string.- Parameters:
encoding
- the ISO encoding name- See Also:
XmlOptions.setCharacterEncoding(java.lang.String)
-
getEncoding
Returns the encoding used for the XML document, as an ISO encoding name. -
setVersion
Sets the XML version string to use in the <?xml?> declaration. (The XML specification is quite stable at "1.0".)- Parameters:
version
- the XML version string
-
getVersion
Returns the XML version string used in the <?xml?> declaration. -
setStandalone
public void setStandalone(boolean standalone)Sets the standalone property.- Parameters:
standalone
- whether standalone is true or not
-
getStandalone
public boolean getStandalone()Returns the standalone property -
setDoctypeName
Sets the DOCTYPE name use in the <!DOCTYPE> declaration.- Parameters:
doctypename
- the doctypename
-
getDoctypeName
Returns the DOCTYPE name used in the <!DOCTYPE> declaration. -
setDoctypePublicId
Sets the DOCTYPE public ID to use in the <!DOCTYPE> declaration.- Parameters:
publicid
- the public ID
-
getDoctypePublicId
Returns the DOCTYPE public ID used in the <!DOCTYPE> declaration. -
setDoctypeSystemId
Sets the DOCTYPE system ID to use in the <!DOCTYPE> declaration.- Parameters:
systemid
- the system ID
-
getDoctypeSystemId
Returns the DOCTYPE system ID used in the <!DOCTYPE> declaration. -
setMessageDigest
public void setMessageDigest(byte[] digest)Sets the message digest used to summarize the document.- Parameters:
digest
- the bytes of the digest- See Also:
XmlOptions.setLoadMessageDigest()
-
getMessageDigest
public byte[] getMessageDigest()Returns the message digest used to summarize the document.- See Also:
XmlOptions.setLoadMessageDigest()
-
put
Attaches a value to the root of the document containing the given token source.- Parameters:
key
- The key: there can be one value for each key.value
- The value to attach to the document.
-
get
Returns a value previously attached to a document using set.- Parameters:
key
- The key: this is the key that was previously passed to set to store the value.- Returns:
- The saved value, or null if none is found.
-
remove
Removes a value previously attached to a document using set.- Parameters:
key
- The key: this is the key that was previously passed to set to store the value.
-