public final class XIncludeScheme extends Object implements SimpleInclusionScheme
XInclude
,
XInclude 1.0,
XInclude 1.1Modifier and Type | Class and Description |
---|---|
static class |
XIncludeScheme.Option
Option keys supported by the options argument of
createSimpleInclusion(com.xmlmind.xml.doc.Node, com.xmlmind.xml.doc.Node, boolean, java.lang.String, java.util.Map<java.lang.Object, java.lang.Object>, com.xmlmind.xml.load.SimpleInclusion[]) . |
Modifier and Type | Field and Description |
---|---|
static SimpleInclusionScheme[] |
AS_LIST
A 1-element array containing a ready-to-use instance of this scheme.
|
static XIncludeScheme |
INSTANCE
A ready-to-use instance of this scheme.
|
Constructor and Description |
---|
XIncludeScheme() |
Modifier and Type | Method and Description |
---|---|
static String |
computeXPointer(Node firstNode,
Node lastNode)
Helper function: compute the XPointer corresponding
to specified node range.
|
boolean |
createSimpleInclusion(Node firstNode,
Node lastNode,
boolean createAbsoluteReference,
String absoluteReference,
Map<Object,Object> options,
SimpleInclusion[] created)
Create and return an SimpleInclusion representing specified nodes.
|
boolean |
detectXInclusion(Node[] directive,
boolean isElement,
XInclusion[] detected)
Create and return the XInclusion corresponding to specified directive,
when such directive has been recognized by this scheme.
|
static boolean |
elementXPointer(Element element,
Map<Element,String> elementToId,
StringBuilder buffer) |
Attribute[] |
getCopiedAttributes() |
Attribute[] |
getCopiedAttributesWhenMultipleInstances() |
String |
getSchemeName()
Returns a name identifying uniquely this scheme.
|
Includable[] |
listIncludables(Document targetDoc)
Lists obvious node ranges (typically a single element having an ID)
found in specified document which could be successfully copied
by reference using
SimpleInclusionScheme.createSimpleInclusion(com.xmlmind.xml.doc.Node, com.xmlmind.xml.doc.Node, boolean, java.lang.String, java.util.Map<java.lang.Object, java.lang.Object>, com.xmlmind.xml.load.SimpleInclusion[]) . |
void |
setCopiedAttributes(Attribute[] attrs) |
void |
setCopiedAttributes(String spec) |
void |
setCopiedAttributesWhenMultipleInstances(Attribute[] attrs) |
void |
setCopiedAttributesWhenMultipleInstances(String spec) |
public static final XIncludeScheme INSTANCE
public static final SimpleInclusionScheme[] AS_LIST
public void setCopiedAttributesWhenMultipleInstances(String spec) throws IllegalArgumentException
IllegalArgumentException
public void setCopiedAttributesWhenMultipleInstances(Attribute[] attrs)
public void setCopiedAttributes(String spec) throws IllegalArgumentException
IllegalArgumentException
public void setCopiedAttributes(Attribute[] attrs)
public Attribute[] getCopiedAttributesWhenMultipleInstances()
public Attribute[] getCopiedAttributes()
public String getSchemeName()
XInclusionScheme
getSchemeName
in interface XInclusionScheme
public boolean detectXInclusion(Node[] directive, boolean isElement, XInclusion[] detected) throws InclusionException
XInclusionScheme
detectXInclusion
in interface XInclusionScheme
directive
- an array of two nodes initially containing
the same node: an element or a processing-instruction.
Nodes other than elements or processing-instructions cannot be used as inclusion directives.
The node passed as an argument is attached to the document being processed. By examining this node, this scheme must very quickly determine whether the node acts as an inclusion directive.
In some cases, the node contained in directive[0]
is just the start of the inclusion directive. In such case, this scheme
must set directive[1]
to the node which is the end of the
inclusion directive.
Example:
<?begin-inclusion spec="..."?> ...pre-included nodes, to be updated... <?end-inclusion>
isElement
- true
if directive[0]
contains an element; false
if directive[0]
contains a processing-instructiondetected
- newly created XInclusion, if any, is assigned to
detected[0]
. May be null
(just a test,
no creation of an XInclusion object).true
if passed node has been recognized
as an inclusion directive; otherwise false
InclusionException
- if the directive has been recognized
but cannot be successfully parsedpublic boolean createSimpleInclusion(Node firstNode, Node lastNode, boolean createAbsoluteReference, String absoluteReference, Map<Object,Object> options, SimpleInclusion[] created)
SimpleInclusionScheme
This method is needed to implement the copyAsInclusion command.
createSimpleInclusion
in interface SimpleInclusionScheme
firstNode
- first node to be representedlastNode
- last node to be represented.
firstNode and lastNode specify a node range which is attached to the document tree. None of these nodes has already been included.
createAbsoluteReference
- use absolute rather relative URL
in created SimpleInclusion.
This parameter may be ignored if not meaningful.absoluteReference
- the XML catalog resolved
absolute reference to use.
Ignored if createAbsoluteReference is false
.
If createAbsoluteReference is true
:
null
, a absolute URL determined using
firstNode/lastNode is used.
options
- scheme-specific options other than
createAbsoluteReference. May be null
.
This parameter may be ignored if not meaningful.created
- an SimpleInclusion representing specified nodes, if any,
is assigned to created
. May be null
(just a test, no creation of a SimpleInclusion object).true
if a SimpleInclusion representing
specified nodes can be/has been created; false
otherwisepublic static String computeXPointer(Node firstNode, Node lastNode)
firstNode
- first node of the rangelastNode
- last node of the range. May be identical to
firstNode.null
if it cannot
be computed (typically because specified range is incorrect)public static boolean elementXPointer(Element element, Map<Element,String> elementToId, StringBuilder buffer)
public Includable[] listIncludables(Document targetDoc)
SimpleInclusionScheme
SimpleInclusionScheme.createSimpleInclusion(com.xmlmind.xml.doc.Node, com.xmlmind.xml.doc.Node, boolean, java.lang.String, java.util.Map<java.lang.Object, java.lang.Object>, com.xmlmind.xml.load.SimpleInclusion[])
.
This method is needed to implement the include command.
listIncludables
in interface SimpleInclusionScheme
targetDoc
- the document to be searched for includable nodesnull
or empty.