|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.nds.dirxml.util.DocumentTemplate
This class takes a template string containing replacement tokens and generates strings with substitutions made for the tokens. The replacement values come from an XML document.
In particular: A replacement token in the source string is specified by surrounding a token identifier with '$' (dollar) characters. The token identifier may be any legal XML name. The replacement values are obtained from a passed XML document. If an XML attribute's name matches a replacement token identifier then the attribute's value is substituted for the replacement token. If the name of the parent element of a text node matches a replacement token identifier then the text node value replaces the token. This class is designed primarily for templates that are serialized XML documents whose replacement token values should come from another XML document. E.g., Template string:static final String SYNC_STRING = "<nds><input>" + "<sync src-dn='$src-dn$' qualified-src-dn='$qualified-src-dn$' class-name='$class-name$'>" + "<association>$association$</association>" + "</sync>" + "</input></nds>";Replacement value document:
<nds> <output> <instance class-name='User' src-dn='\\TREE\\novell\\jdoe' qualified-src-dn='O=novell\\CN=jdoe'> <association>1234</association> </instance> </output> </nds>Result string:
"<nds><input>" + "<sync src-dn='\\TREE\\novell\\jdoe' qualified-src-dn='O=novell\\CN=jdoe' class-name='User'>" + "<association>1234</association>" + "</sync>" + "</input></nds>";
Constructor Summary | |
DocumentTemplate(String template)
Construct a DocumentTemplate instance from a template String containing
zero or more replacement tokens. |
Method Summary | |
Document |
getMappedDocument(Map replacementMap)
Get a DOM representation of the template String with all replacement tokens
replaced. |
Document |
getMappedDocument(Node replacementSource)
Get a DOM representation of the template String with all replacement tokens
replaced. |
String |
getMappedString(Map replacementMap)
Get the template String with all replacement tokens replaced. |
String |
getMappedString(Node replacementSource)
Get the template String with all replacement tokens replaced. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DocumentTemplate(String template)
DocumentTemplate
instance from a template String
containing
zero or more replacement tokens.
template
- the template String
Method Detail |
public String getMappedString(Node replacementSource)
String
with all replacement tokens replaced.
replacementSource
- DOM node that is the top of the subtree containing
values for the replacement tokens
String
public String getMappedString(Map replacementMap)
String
with all replacement tokens replaced.
replacementMap
- mapping between token identifiers and values
String
public Document getMappedDocument(Node replacementSource)
String
with all replacement tokens
replaced. If the template String
is not a valid, serialized XML document then
the return value will be null
.
replacementSource
- DOM node that is the top of the subtree containing
values for the replacement tokens
null
public Document getMappedDocument(Map replacementMap)
String
with all replacement tokens
replaced. If the template String
is not a valid, serialized XML document then
the return value will be null
.
replacementMap
- mapping between token identifiers and values
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |