Package org.mycore.common.xml
Class MCRDynamicURIResolver
java.lang.Object
org.mycore.common.xml.MCRDynamicURIResolver
- All Implemented Interfaces:
URIResolver
Extend this class to include dynamic jdom content. The content is loaded
from a xml file, which have to be set by the setXmlFile
method.
The dynamic comes into play by the variables that can be defined for the uri. In general they are set directly behind the uri prefix. For example:
uriprefix:value1:value2:value3... or uriprefix:varname1=varvalue1:varname2=varvalue2:varname3=varname3...In the xml file you can use these variables with curly brackets '{}'. For more informations about the syntax see
MCRTextResolver
. Heres only a short example
what is possible:
myURIResolver:classId=class_000_1:levels=-1:axis=children
<dynIncl> <panel> <hidden var="@classid" default="{classId}"/> <include uri="dynClassification:editor:{levels}:{axis}:{classId}[:{categId}]"/> <panel/> </dynIncl>
- Author:
- Matthias Eichner
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateVariablesMap
(String uri) This method creates a hashtable that contains variables.protected Element
resolveElement
(String uri) protected void
resolveVariablesFromElement
(Element startElement, Hashtable<String, String> variablesMap) This method runs through the whole content of the startElement and tries to resolve all variables in texts and attributes.void
setXmlFile
(File xmlFile) Sets the xml file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.xml.transform.URIResolver
resolve
-
Field Details
-
cachedElement
-
xmlFile
-
lastModified
protected long lastModified
-
-
Constructor Details
-
MCRDynamicURIResolver
public MCRDynamicURIResolver()
-
-
Method Details
-
setXmlFile
Sets the xml file. From this file the jdom content will be created.- Parameters:
xmlFile
- xml file object
-
resolveElement
- Throws:
Exception
-
getRootElement
-
createVariablesMap
This method creates a hashtable that contains variables. There are two possibilities for getting the name of a variable from the uri:- uriprefix:value1:value2:value3
- uriprefix:varname1=varvalue1:varname2=varvalue2:varname3=varname3
For the first option the name of the variables is 'x', where 'x' is a number for the position in the uri. To get the first value use {1}, to get the second one use {2} and so on.- Parameters:
uri
- the whole uri- Returns:
- a hashtable with all variables from the uri
-
resolveVariablesFromElement
protected void resolveVariablesFromElement(Element startElement, Hashtable<String, String> variablesMap) This method runs through the whole content of the startElement and tries to resolve all variables in texts and attributes.- Parameters:
startElement
- where to start to resolve the variablesvariablesMap
- a map of all variables
-