public final class XInclude extends Object implements SimpleInclusion
XIncludeScheme
,
XInclude 1.0,
XInclude 1.1Modifier and Type | Field and Description |
---|---|
String |
absoluteHref
String representation of
href , the above URL. |
Attribute[] |
attributes
Other attributes of the xi:include element.
|
Element |
fallback
The xi:fallback element if any.
|
String |
fragid
The string representation of the fragment identifier.
|
URL |
href
The URL of the document containing the nodes to be included (AKA the
target document).
|
boolean |
parseText
true if the target document is to be included as text;
false otherwise. |
String |
textEncoding
The encoding of the target document.
|
String |
xpointer
The string representation of the XPointer.
|
Constructor and Description |
---|
XInclude(String clipboardForm)
Constructs an XInclude initialized using specified clipboard form.
|
XInclude(URL href,
String absoluteHref,
String xpointer,
String fragid,
boolean parseText,
String textEncoding,
Attribute[] attributes,
Element fallback) |
Modifier and Type | Method and Description |
---|---|
Node[] |
copySourceNodes(Node firstNode,
Node lastNode)
Returns nodes to be included, which are copies, as is (XInclude 1.0) or
modified (DITA Conref, XInclude 1.1), of specified source nodes.
|
static XInclude |
fromElement(Element element)
Creates an XInclude object representing specified xi:include
element.
|
String |
getSchemeName()
Returns the name of the XInclusion scheme which has created this
XInclusion.
|
Node[] |
getSourceNodes(Document sourceDocument,
Node inclusionHolder)
Returns the original nodes.
|
URL |
getSourceURL(Node inclusionHolder)
Returns the URL of document from which the nodes have been included.
|
boolean |
hasSimpleXPointer()
Returns
true if this XInclude object has no xpointer or
has a xpointer using the element() scheme and
containing an ID (id
or element(id) ) or pointing to the root element of
the document (element(/1) ). |
Node[] |
include(Node firstNode,
Node lastNode,
boolean updating,
XInclusionContext context)
Creates and returns the included nodes corresponding to this XInclusion.
|
boolean |
isMarkedForUpdate()
Returns
true if this XInclusion has been marked for update
using XInclusion.setMarkedForUpdate(boolean) ; false otherwise
This method is exclusively for use by the XIncluder. |
void |
setMarkedForUpdate(boolean mark)
Mark this inclusion for update.
|
String |
toClipboardForm()
Returns a parseable string representation of this inclusion.
|
static String |
toHref(NodeIterator nodeIter) |
String |
toString() |
Node[] |
uninclude(Node firstIncludedNode,
Node lastIncludedNode)
Creates and returns one or more nodes acting as the inclusion directive
which allows to obtain specified nodes.
|
public final URL href
null
.public final String absoluteHref
href
, the above URL.
null
if the above URL was specified as a relative URL.
This string representation is needed because it may make use of XML catalog trick (Example: foo:bar/gee.xml, where foo: is resolved using an XML catalog).
public final String xpointer
null
.public final String fragid
null
.public final boolean parseText
true
if the target document is to be included as text;
false
otherwise.public final String textEncoding
public final Attribute[] attributes
null
.
These attributes are used to implement the Attribute Copying feature of XInclude 1.1. Example: set-xml-id.
public final Element fallback
null
.public XInclude(URL href, String absoluteHref, String xpointer, String fragid, boolean parseText, String textEncoding, Attribute[] attributes, Element fallback) throws InclusionException
InclusionException
public XInclude(String clipboardForm) throws InclusionException
InclusionException
toClipboardForm()
public String getSchemeName()
XInclusion
XInclusionScheme.getSchemeName()
.getSchemeName
in interface XInclusion
public static XInclude fromElement(Element element) throws InclusionException
element
- The xi:include element to be converted.InclusionException
- if, for any reason, specified element
cannot be converted to an an XInclude object.public boolean hasSimpleXPointer()
true
if this XInclude object has no xpointer or
has a xpointer using the element() scheme and
containing an ID (id
or element(id)
) or pointing to the root element of
the document (element(/1)
). Returns false
otherwise.public void setMarkedForUpdate(boolean mark)
XInclusion
Application code does this to signal the XIncluded that the included nodes attached to this XInclusion need to be ``refreshed''.
setMarkedForUpdate
in interface XInclusion
public boolean isMarkedForUpdate()
XInclusion
true
if this XInclusion has been marked for update
using XInclusion.setMarkedForUpdate(boolean)
; false
otherwise
This method is exclusively for use by the XIncluder.
isMarkedForUpdate
in interface XInclusion
public Node[] include(Node firstNode, Node lastNode, boolean updating, XInclusionContext context) throws InclusionException
XInclusion
include
in interface XInclusion
firstNode
- first node to be replaced by those returned
by this method.lastNode
- last node to be replaced by those returned
by this method.
firstNode and lastNode specify a node range attached to the document tree.
updating
- if true
, firstNode and
lastNode specify an included node range to be replaced
by a more up-to-date included node range. If false
,
firstNode and lastNode specify an inclusion directive
to be replaced by an included node range.Included nodes are copies of some ``original nodes''.
These copies are not always clones of the original nodes (e.g. DITA conref).
The returned nodes must each have a
Constants.SOURCE_URL_PROPERTY
property
properly set.
On the other hand, adding the
Constants.INCLUSION_PROPERTY
and
Constants.READ_ONLY_PROPERTY
properties
to returned nodes is not useful.
InclusionException
- if this XInclusion fails to
locate the original nodespublic Node[] uninclude(Node firstIncludedNode, Node lastIncludedNode)
XInclusion
For example, if this XInclusion is an XInclude, this method returns an <xi:include> element having the proper attributes.
uninclude
in interface XInclusion
firstIncludedNode
- first node in the included node range
having this XInclusion object as its
Constants.INCLUSION_PROPERTY
property.
This node is attached to the document being processed.lastIncludedNode
- last node in the included node range
having this XInclusion object as its
Constants.INCLUSION_PROPERTY
property
This node, a sibling of lastIncludedNode, is also attached to
the document being processed.public String toClipboardForm()
Inclusion
toClipboardForm
in interface Inclusion
public URL getSourceURL(Node inclusionHolder)
SimpleInclusion
null
(e.g. unresolved DITA conkeyref).getSourceURL
in interface SimpleInclusion
inclusionHolder
- one of the included nodes, that is, one
of the nodes having an INCLUSION_PROPERTY property pointing
to this SimpleInclusion.
Generally this parameter is not used.
public Node[] getSourceNodes(Document sourceDocument, Node inclusionHolder) throws InclusionException
SimpleInclusion
getSourceNodes
in interface SimpleInclusion
sourceDocument
- the document containing the original nodes.
The URL of this document is returned by SimpleInclusion.getSourceURL(com.xmlmind.xml.doc.Node)
.
inclusionHolder
- one of the included nodes, that is, one
of the nodes having an INCLUSION_PROPERTY property pointing
to this SimpleInclusion.
Generally this parameter is not used.
InclusionException
- if this SimpleInclusion fails to
locate the original nodespublic Node[] copySourceNodes(Node firstNode, Node lastNode)
SimpleInclusion
This method is needed to implement the copyAsInclusion command.
copySourceNodes
in interface SimpleInclusion
firstNode
- first source node represented by this inclusion objectlastNode
- last source node represented by this inclusion object
firstNode and lastNode specify a node range which is attached to the document tree. None of these nodes has already been included.
public static String toHref(NodeIterator nodeIter)