xpe(3) | AFNIX Service | xpe(3) |
xpe - xml processing environment service
The XML Processing Environmentservice is an original implementation that provides the support for processing xml document that could be accessed locally or remotely. In particular, the processing environment supports the XML includefacility.
XML content
The XmlContentclass is an extension of the XML document object that provides
the service for loading a XML document locally or from the Internet. The
class operates with an uri, which permits to selects the appropriate loader
from the uri scheme.
Content creation
The XmlContentoperates with an uri that permits to select the appropriate
loader. If the uri scheme is a file scheme, the content is retrieved
locally. If the uri scheme is http, the content is retrieved by establishing
a http connection over the Internet.
# create a document from a local file const xdoc (
afnix:xpe:XmlContent "file:///home/afnix/file.xml")
When the uri scheme is a file, the uri authority is empty (hence the double //) and the path indicates the file to parse. The XmlContent object is derived from the XmlDocumentobject which contains the parsed tree with the XmlRootobject.
# create a document from a http connection const xdoc (
afnix:xpe:XmlContent
"http://www.afnix.org/index.xht")
When the uri scheme is a http scheme, the document is downloaded by establishing an http connection with the uri authority. When the http header is received, the content is parsed to create a valid xml document. If the http response header indicates that the page has moved and a new location is provided, the object manages automatically to follow such location.
Content and document name
Since the XmlContentobject is derived from the XmlContentobject, the content
object is defined with a uri name and a document name. Under normal
circumstances, the document name is derived from the content name by
normalizing it. The content name is the object constructor name, while the
document name is the normalized document name. The get-namemethod returns
the content name while the get-document-namemethod returns the document
name.
# create a document by name const xdoc (afnix:xpe:XmlContent "file" "file.xml")
In the previous example, a xml content object is created by name with a document name. It is the document name that gets normalized. Therefore in the previous example, the file.xmldocument name is normalized into a file uri. The normalization rule always favor the file scheme. This means that without a scheme, the file scheme is automatically added.
Content type
Many times, the content type cannot be detected from the uri name. Once
opened, if the content header provides a clue about the content type, the
opened input stream get adjusted automatically to reflect this fact.
However, this situation does not occurs often and with http scheme, the
content type header response does not often provides the character encoding
associated with the stream. For this reason, the XmlContentconstructor
provides a mechanism to accept the encoding mode.
# create a new content by name and encoding mode const xdoc (
afnix:xpe:XmlContent "file" "file.xml" "UTF-8")
XmlContent
The XmlContentclass is an extension of the xml document class that operates at
the uri level. If the uri is a local file the xml document is created from
an input file stream. If the uri is an url, the content is fetched
automatically. The class constructors permit to separate the content name
from the document name and also to specify the content encoding.
Predicate
Inheritance
Constructors
Methods
XmlFeature
The XmlFeatureclass is a xml processor base class that defines a processing
feature. A processing feature is defined by name and information with a
processing level. The default processing level is null. When the processor
is called, it calls sequentially and in ascending order all features.
Predicate
Inheritance
Methods
XmlProcessor
The XmlProcessorclass is a global class designed to operate on a xml content.
The xml processor provides several features that can be enabled prior the
document processor. Once the features are defined, the 'process' method can
be called and a new xml content can be produced.
Predicate
Inheritance
Constructors
Methods
XmlInclude
The XmlIncludeclass is a xml processor feature class designed to handle the
"XInclude" schema that permits to include xml document. The
feature operates recursively by scanning the document for a
"xi:include" tag and replacing the content by the appropriate
tree. The feature operates recursively unless specified otherwise.
Predicate
Inheritance
Constructors
2018-07-20 | AFNIX |