本文整理汇总了Java中freemarker.ext.dom.NodeModel类的典型用法代码示例。如果您正苦于以下问题:Java NodeModel类的具体用法?Java NodeModel怎么用?Java NodeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeModel类属于freemarker.ext.dom包,在下文中一共展示了NodeModel类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getXmlNodeModel
import freemarker.ext.dom.NodeModel; //导入依赖的package包/类
/**
* @return FreeMarker NodeModel for the XML content of this node, or null if no parsable XML found
*/
public NodeModel getXmlNodeModel()
{
try
{
return NodeModel.parse(new InputSource(new StringReader(getContent())));
}
catch (Throwable err)
{
if (logger.isDebugEnabled())
logger.debug(err.getMessage(), err);
return null;
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:TemplateNode.java
示例2: processWfsEntity
import freemarker.ext.dom.NodeModel; //导入依赖的package包/类
public static String processWfsEntity(String entityName, Node domNode, String templatePath) throws TemplateException, FileNotFoundException, IOException, URISyntaxException {
String result = null;
NodeModel nodeModel = NodeModel.wrap(domNode);
Map<String, Object> ctx = FastMap.newInstance();
ctx.put("doc", nodeModel);
ctx.put("entityName", entityName);
StringWriter outWriter = new StringWriter();
Template template = getDocTemplate(templatePath);
template.process(ctx, outWriter);
outWriter.close();
result = outWriter.toString();
return result;
}
开发者ID:gildaslemoal,项目名称:elpi,代码行数:14,代码来源:WfsEventHandler.java
示例3: getRootNode
import freemarker.ext.dom.NodeModel; //导入依赖的package包/类
private Node getRootNode(NodeModel model) {
NodeList list = model.getNode().getChildNodes();
for (int i=0; i<list.getLength(); i++) {
Node n = list.item(i);
if (n instanceof Element) {
return n;
}
}
throw new IllegalStateException("Can't find root node!");
}
开发者ID:betfair,项目名称:cougar,代码行数:11,代码来源:IDLReader.java
示例4: init
import freemarker.ext.dom.NodeModel; //导入依赖的package包/类
public void init(
Document iddDoc,
Document extensionDoc,
final String service,
String packageName,
final String basedir,
final String genSrcDir,
final Log log,
final String outputDir,
boolean client,
boolean server)
throws Exception {
try {
output = new File(basedir, genSrcDir);
if (outputDir != null) {
iDDOutputDir = new File(basedir+"/"+outputDir);
if (!iDDOutputDir.exists()) {
if (!iDDOutputDir.mkdirs()) {
throw new IllegalArgumentException("IDD Output Directory "+iDDOutputDir+" could not be created");
}
}
if (!iDDOutputDir.isDirectory() || (!iDDOutputDir.canWrite())) {
throw new IllegalArgumentException("IDD Output Directory "+iDDOutputDir+" is not a directory or cannot be written to.");
}
}
config = new Configuration();
config.setClassForTemplateLoading(IDLReader.class, "/templates");
config.setStrictSyntaxMode(true);
this.log = log;
this.packageName = packageName;
this.service = service;
this.client = client;
this.server = server || !client; // server must be true if client if false.
dataModel = NodeModel.wrap(iddDoc.cloneNode(true));
if (extensionDoc != null) {
NodeModel extensionModel = NodeModel.wrap(extensionDoc);
mergeExtensionsIntoDocument(getRootNode(dataModel),
getRootNode(extensionModel));
removeUndefinedOperations(getRootNode(dataModel),
getRootNode(extensionModel));
}
if(log.isDebugEnabled()) {
log.debug(serialize());
}
} catch (final Exception e) {
log.error("Failed to initialise FTL", e);
throw e;
}
}
开发者ID:betfair,项目名称:cougar,代码行数:54,代码来源:IDLReader.java
示例5: writeTemplate
import freemarker.ext.dom.NodeModel; //导入依赖的package包/类
private void writeTemplate(final Transformation trans, final NodeModel topLevelDoc, final NodeModel data, final String paramName, final List<NodeModel> paramNodes, final String pkg, final String serviceName, final String majorVersion, final String majorMinorVersion, String name, String dirName)
throws Exception {
log.debug(trans.toString());
String nsVersion = majorVersion;
String namespace = "http://www.betfair.com/servicetypes/"+nsVersion+"/"+serviceName+"/";
final Map<String, Object> root = new HashMap<String, Object>();
root.put("interface", topLevelDoc);
root.put("doc", data);
root.put("package", pkg.replaceAll("/", "\\."));
root.put("majorVersion", majorVersion);
root.put("majorMinorVersion", majorMinorVersion);
root.put("name", name);
root.put("namespace", namespace);
if (paramName != null) {
if (paramNodes.size() == 1) {
root.put(paramName, paramNodes.get(0));
}
else {
root.put(paramName, paramNodes);
}
}
final File outputDirectory = new File(output, dirName);
name = name.trim();
name = capFirst(name);
final String fileName = trans.getFileName().replace("${name}", name);
final String className = fileName.replace(".java", "");
File outputFile = new File(outputDirectory, fileName);
FileWriter fw = new FileWriter(outputFile);
root.put("className", className);
log.debug("Writing " + name + " using template " + trans.getTemplate() + " to file " + outputFile);
try {
// First thing is to deal with the service
final Template template = config.getTemplate(trans.getTemplate());
template.process(root, fw);
} finally {
fw.close();
//write the jaxb.index file
if(trans.isJaxb()) {
outputFile = new File(outputDirectory, "jaxb.index");
fw = new FileWriter(outputFile,true);
fw.append(className).append("\n");
fw.close();
outputFile = new File(outputDirectory, "package-info.java");
fw = new FileWriter(outputFile);
fw.write("@javax.xml.bind.annotation.XmlAccessorOrder(javax.xml.bind.annotation.XmlAccessOrder.UNDEFINED)\n");
fw.write("@javax.xml.bind.annotation.XmlSchema(namespace=\""+namespace+"\",elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED)\n");
fw.write("package "+dirName.replaceAll("/", ".")+";");
fw.close();
}
}
}
开发者ID:betfair,项目名称:cougar,代码行数:55,代码来源:IDLReader.java
注:本文中的freemarker.ext.dom.NodeModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论