本文整理汇总了Java中org.jdom.transform.JDOMSource类的典型用法代码示例。如果您正苦于以下问题:Java JDOMSource类的具体用法?Java JDOMSource怎么用?Java JDOMSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDOMSource类属于org.jdom.transform包,在下文中一共展示了JDOMSource类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDocumentation
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
@Nullable
private String getDocumentation(String name, String type) {
try {
final Transformer transformer = getTemplate().newTransformer();
transformer.setParameter("element", name);
transformer.setParameter("type", type);
final StringWriter writer = new StringWriter();
transformer.transform(new JDOMSource(getDocumentationDocument()), new StreamResult(writer));
final String s = writer.toString();
final Matcher matcher = check.matcher(s);
if (matcher.find()) {
if (matcher.group(1).equals("true")) {
return s.replaceFirst("<META.+?>", "");
}
}
} catch (Exception e) {
Logger.getInstance(getClass().getName()).error(e);
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XsltDocumentationProvider.java
示例2: write
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
public void write(Writer writer) throws IOException, JDOMException
{
try
{
Source source = new JDOMSource(doc);
Result result = new StreamResult(writer);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
transformer.transform(source, result);
}
catch (TransformerException e)
{
throw new XFormsConstructionException(e);
}
}
开发者ID:NCIP,项目名称:edct-formbuilder,代码行数:24,代码来源:XForm.java
示例3: sendCoverageOfferingsList
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
public void sendCoverageOfferingsList(HttpServletRequest request,
HttpServletResponse response,
String projectName,
String siteName,
String serviceName)
throws Exception {
Request oRequest = new Request(null,request);
String collectionName = Scrub.urlContent(ReqInfo.getLocalUrl(request));
if (collectionName.endsWith("/contents.html")) {
collectionName = collectionName.substring(0, collectionName.lastIndexOf("contents.html"));
}
if (!collectionName.endsWith("/"))
collectionName += "/";
log.debug("collectionName: " + collectionName);
/*
Element root = newDataset(collectionName, false, true, size, new Date());
root.setAttribute("prefix", "/");
catalog.setRootElement(root);
*/
Project project = WcsManager.getProject(projectName);
if (project == null) {
log.error("sendCoverageOfferingsList() Project: \"" + projectName + "\" not found.");
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
Site site = project.getSite(siteName);
if (site == null) {
log.error("sendCoverageOfferingsList() Site: \"" + siteName + "\" not found.");
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
WcsService service = WcsManager.getWcsService(serviceName);
if (service == null) {
log.error("sendCoverageOfferingsList() WcsService: \"" + serviceName + "\" not found.");
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
String xsltDoc = ServletUtil.getSystemPath(dispatchServlet, "/xsl/wcs_coveragesList.xsl");
Transformer transformer = new Transformer(xsltDoc);
transformer.setParameter("dapService", oRequest.getDapServiceLocalID());
transformer.setParameter("docsService", oRequest.getDocsServiceLocalID());
response.setContentType("text/html");
response.setHeader("Content-Description", "wcs_coverages_list");
ReentrantReadWriteLock.ReadLock lock = service.getReadLock();
try {
lock.lock();
Document capDoc = service.getCapabilitiesDocument();
transformer.transform(new JDOMSource(capDoc), response.getOutputStream());
log.debug("Used saxon to send THREDDS catalog (XML->XSLT(saxon)->HTML).");
}
finally {
lock.unlock();
}
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:79,代码来源:WcsDispatchHandler.java
示例4: sendNormativeRepresentation
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
@Override
public void sendNormativeRepresentation(HttpServletRequest request, HttpServletResponse response) throws Exception {
String context = request.getContextPath()+"/";
String relativeUrl = ReqInfo.getLocalUrl(request);
String baseUrl = Util.dropSuffixFrom(relativeUrl, normDSR.getRequestSuffixMatchPattern());
baseUrl = PathBuilder.pathConcat(context,baseUrl);
Document responseDoc = new Document();
HashMap<String,String> piMap = new HashMap<>( 2 );
piMap.put( "type", "text/xsl" );
piMap.put( "href", context+"xsl/datasetServices.xsl" );
ProcessingInstruction pi = new ProcessingInstruction( "xml-stylesheet", piMap );
responseDoc.addContent(pi);
Element datasetServices;
log.debug("Sending {} for dataset: {}",getServiceTitle(),baseUrl);
datasetServices = normDSR.getDatasetServicesElement(baseUrl);
responseDoc.setRootElement(datasetServices);
String currentDir = System.getProperty("user.dir");
log.debug("Cached working directory: "+currentDir);
String xslDir = new PathBuilder(_systemPath).pathAppend("xsl").toString();
log.debug("Changing working directory to "+ xslDir);
System.setProperty("user.dir",xslDir);
try {
String xsltDocName = "datasetServices.xsl";
Transformer transformer = new Transformer(xsltDocName);
ServletOutputStream os = response.getOutputStream();
MediaType responseMediaType = getNormativeMediaType();
// Stash the Media type in case there's an error. That way the error handler will know how to encode the error.
RequestCache.put(OPeNDAPException.ERROR_RESPONSE_MEDIA_TYPE_KEY, responseMediaType);
response.setContentType(responseMediaType.getMimeType());
response.setHeader("Content-Description", getNormativeMediaType().getMimeType());
// Transform the DSR into an HTML page.
transformer.transform(new JDOMSource(responseDoc), os);
log.debug("Sent {}", getServiceTitle());
}
finally {
System.setProperty("user.dir", currentDir);
}
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:51,代码来源:HtmlDSR.java
示例5: sendBesCatalogAsHtml
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
/**
* Transmits a BES catalog document as a w10n meta response encoded as HTML (srsly.)
*
* @param w10nRequest The w10n request to be serviced.
* @param showCatalogDoc The BES showCatalog response document.
* @param response The outgoing response.
* @throws SaxonApiException
* @throws IOException
*/
private void sendBesCatalogAsHtml(W10nRequest w10nRequest, Document showCatalogDoc, HttpServletResponse response) throws SaxonApiException, IOException {
Request oreq = new Request(null,w10nRequest.getServletRequest());
JDOMSource besCatalog = new JDOMSource(showCatalogDoc);
String xsltDoc = _systemPath + "/xsl/w10nCatalog.xsl";
Transformer transformer = new Transformer(xsltDoc);
transformer.setParameter("dapService",oreq.getServiceLocalId());
transformer.setParameter("docsService",oreq.getDocsServiceLocalID());
if(BesDapDispatcher.allowDirectDataSourceAccess())
transformer.setParameter("allowDirectDataSourceAccess","true");
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(besCatalog, response.getOutputStream());
// transformer.transform(besCatalog, System.out);
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:34,代码来源:W10nResponder.java
示例6: checkXML
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
/**
* Validate XML of the created bill against the appropriate schema. Subclasses can override to
* provide specific handling of errors. The default implementation will mark the bill as
* erroneous if STRICT_BILLING is active and XML Schema errors are present.
*
* @param xmlDoc
* the bill
* @param dest
* the destination path if the user chose output to file. Might be null
* @param rn
* the bill to output
* @param doVerify
* false if the user doesn't want strict validity check (subclasses may ignore)
*/
protected void checkXML(final Document xmlDoc, String dest, final Rechnung rn,
final boolean doVerify){
if (CoreHub.userCfg.get(Preferences.LEISTUNGSCODES_BILLING_STRICT, true)) {
Source source = new JDOMSource(xmlDoc);
String path =
PlatformHelper.getBasePath("ch.elexis.base.ch.arzttarife") + File.separator + "rsc"; //$NON-NLS-1$ //$NON-NLS-2$
List<String> errs = null;
// validate depending on tarmed version
if (getXmlVersion(xmlDoc.getRootElement()).equals("4.0")) {
logger.info("Validating XML against MDInvoiceRequest_400.xsd");
errs =
XMLTool.validateSchema(
path + File.separator + "MDInvoiceRequest_400.xsd", source); //$NON-NLS-1$
} else if (getXmlVersion(xmlDoc.getRootElement()).equals("4.4")) {
logger.info("Validating XML against generalInvoiceRequest_440.xsd");
errs =
XMLTool.validateSchema(
path + File.separator + "generalInvoiceRequest_440.xsd", source); //$NON-NLS-1$
} else {
errs =
Collections.singletonList("Bill in unknown XML version "
+ getXmlVersion(xmlDoc.getRootElement()));
}
if (!errs.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (String err : errs) {
sb.append(err).append(StringConstants.LF);
}
logger.error(sb.toString());
rn.reject(RnStatus.REJECTCODE.VALIDATION_ERROR, sb.toString());
XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
StringWriter sw = new StringWriter();
try {
xout.output(xmlDoc, sw);
} catch (IOException e) {
logger.error("Failed getting document as String.", e);
return;
}
logger.debug(sw.toString());
}
}
}
开发者ID:elexis,项目名称:elexis-3-base,代码行数:59,代码来源:XMLExporter.java
示例7: sendDatasetPage
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
private void sendDatasetPage(String webStartService, String docsService, String dapService, String datasetID, Document ddx, OutputStream os) throws IOException, PPTException, BadConfigurationException, SaxonApiException, JDOMException
{
String xsltDoc = ServletUtil.getSystemPath(this, "/xsl/webStartDataset.xsl");
Transformer transformer = new Transformer(xsltDoc);
transformer.setParameter("datasetID",datasetID);
transformer.setParameter("dapService",dapService);
transformer.setParameter("docsService",docsService);
transformer.setParameter("webStartService", webStartService);
String handlers = getHandlersParam(ddx);
_log.debug("Handlers: " + handlers);
if(handlers!=null){
ByteArrayInputStream reader = new ByteArrayInputStream(handlers.getBytes(HyraxStringEncoding.getCharset()));
XdmNode valueNode = transformer.build(new StreamSource(reader));
transformer.setParameter("webStartApplications",valueNode);
}
JDOMSource ddxSource = new JDOMSource(ddx);
transformer.transform(ddxSource, os);
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:31,代码来源:WebStartServlet.java
示例8: sendProjectsPage
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
public void sendProjectsPage(HttpServletRequest req,
HttpServletResponse resp)
throws Exception {
Element p;
long size = 0;
String collectionName = Scrub.urlContent(ReqInfo.getLocalUrl(req));
if (collectionName.endsWith("/contents.html")) {
collectionName = collectionName.substring(0, collectionName.lastIndexOf("contents.html"));
}
if (!collectionName.endsWith("/"))
collectionName += "/";
log.debug("collectionName: " + collectionName);
Element showCatalog = new Element("showCatalog");
Element responseElem = new Element("response");
Element topDataset = newDataset(collectionName, false, true, size, new Date());
showCatalog.addContent(responseElem);
responseElem.addContent(topDataset);
topDataset.setAttribute("prefix", "/");
Collection<Project> projects = WcsManager.getProjects();
for (Project proj : projects) {
//size = proj.getSize();
p = newDataset(proj.getName(), false, true, 0, new Date());
topDataset.addContent(p);
}
JDOMSource besCatalog = new JDOMSource(showCatalog);
Request oreq = new Request(null,req);
String xsltDoc = ServletUtil.getSystemPath(dispatchServlet,"/xsl/contents.xsl");
Transformer transformer = new Transformer(xsltDoc);
transformer.setParameter("dapService",oreq.getDapServiceLocalID());
transformer.setParameter("docsService",oreq.getDocsServiceLocalID());
transformer.setParameter("webStartService",oreq.getWebStartServiceLocalID());
resp.setContentType("text/html");
resp.setHeader("Content-Description", "dods_directory");
resp.setStatus(HttpServletResponse.SC_OK);
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(besCatalog, resp.getOutputStream());
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:63,代码来源:WcsDispatchHandler.java
示例9: sendNormativeRepresentation
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
@Override
public void sendNormativeRepresentation(HttpServletRequest request, HttpServletResponse response) throws Exception {
// String context = request.getContextPath();
String requestedResourceId = ReqInfo.getLocalUrl(request);
String constraintExpression = ReqInfo.getConstraintExpression(request);
String xmlBase = getXmlBase(request);
String resourceID = getResourceId(requestedResourceId, false);
BesApi besApi = getBesApi();
log.debug("Sending {} for dataset: {}",getServiceTitle(),resourceID);
MediaType responseMediaType = getNormativeMediaType();
// Stash the Media type in case there's an error. That way the error handler will know how to encode the error.
RequestCache.put(OPeNDAPException.ERROR_RESPONSE_MEDIA_TYPE_KEY, responseMediaType);
response.setContentType(responseMediaType.getMimeType());
Version.setOpendapMimeHeaders(request, response, besApi);
response.setHeader("Content-Description","ISO 19115 Metadata");
OutputStream os = response.getOutputStream();
String xdap_accept = "3.2";
Document ddx = new Document();
besApi.getDDXDocument(
resourceID,
constraintExpression,
xdap_accept,
xmlBase,
ddx);
ddx.getRootElement().setAttribute("dataset_id",resourceID);
String currentDir = System.getProperty("user.dir");
log.debug("Cached working directory: "+currentDir);
String xslDir = new PathBuilder(_systemPath).pathAppend("nciso").pathAppend("xsl").toString();
log.debug("Changing working directory to "+ xslDir);
System.setProperty("user.dir",xslDir);
try {
String xsltDocName = "ddx2iso.xsl";
// This Transformer class is an attempt at making the use of the saxon-9 API
// a little simpler to use. It makes it easy to set input parameters for the stylesheet.
// See the source code for opendap.xml.Transformer for more.
Transformer transformer = new Transformer(xsltDocName);
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(new JDOMSource(ddx), os);
os.flush();
log.info("Sent {}", getServiceTitle());
}
finally {
log.debug("Restoring working directory to " + currentDir);
System.setProperty("user.dir", currentDir);
}
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:76,代码来源:Iso19115.java
示例10: sendNormativeRepresentation
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
public void sendNormativeRepresentation(HttpServletRequest request, HttpServletResponse response) throws Exception {
// String context = request.getContextPath();
String requestedResourceId = ReqInfo.getLocalUrl(request);
QueryParameters qp = new QueryParameters(request);
String xmlBase = getXmlBase(request);
String resourceID = getResourceId(requestedResourceId, false);
Request oreq = new Request(null,request);
BesApi besApi = getBesApi();
log.debug("Sending {} for dataset: {}",getServiceTitle(),resourceID);
MediaType responseMediaType = getNormativeMediaType();
// Stash the Media type in case there's an error. That way the error handler will know how to encode the error.
RequestCache.put(OPeNDAPException.ERROR_RESPONSE_MEDIA_TYPE_KEY, responseMediaType);
response.setContentType(responseMediaType.getMimeType());
Version.setOpendapMimeHeaders(request, response, besApi);
response.setHeader("Content-Description", getNormativeMediaType().getMimeType());
// Commented because of a bug in the OPeNDAP C++ stuff...
//response.setHeader("Content-Encoding", "plain");
Document dmr = new Document();
besApi.getDMRDocument(
resourceID,
qp,
xmlBase,
dmr);
OutputStream os = response.getOutputStream();
dmr.getRootElement().setAttribute("dataset_id",resourceID);
String currentDir = System.getProperty("user.dir");
log.debug("Cached working directory: "+currentDir);
String xslDir = new PathBuilder(_systemPath).pathAppend("nciso").pathAppend("xsl").toString();
log.debug("Changing working directory to "+ xslDir);
System.setProperty("user.dir",xslDir);
try {
String xsltDocName = "OPeNDAPDDCount-HTML.xsl";
// This Transformer class is an attempt at making the use of the saxon-9 API
// a little simpler to use. It makes it easy to set input parameters for the stylesheet.
// See the source code for opendap.xml.Transformer for more.
Transformer transformer = new Transformer(xsltDocName);
transformer.setParameter("docsService", oreq.getDocsServiceLocalID());
transformer.setParameter("HyraxVersion", Version.getHyraxVersionString());
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(new JDOMSource(dmr), os);
os.flush();
log.info("Sent {}", getServiceTitle());
}
finally {
log.debug("Restoring working directory to " + currentDir);
System.setProperty("user.dir", currentDir);
}
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:82,代码来源:IsoRubricDMR.java
示例11: sendNormativeRepresentation
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
public void sendNormativeRepresentation(HttpServletRequest request, HttpServletResponse response) throws Exception {
// String context = request.getContextPath();
String requestedResourceId = ReqInfo.getLocalUrl(request);
QueryParameters qp = new QueryParameters(request);
String xmlBase = getXmlBase(request);
String resourceID = getResourceId(requestedResourceId, false);
BesApi besApi = getBesApi();
log.debug("Sending {} for dataset: {}",getServiceTitle(),resourceID);
MediaType responseMediaType = getNormativeMediaType();
// Stash the Media type in case there's an error. That way the error handler will know how to encode the error.
RequestCache.put(OPeNDAPException.ERROR_RESPONSE_MEDIA_TYPE_KEY, responseMediaType);
response.setContentType(responseMediaType.getMimeType());
Version.setOpendapMimeHeaders(request, response, besApi);
response.setHeader("Content-Description", getNormativeMediaType().getMimeType());
OutputStream os = response.getOutputStream();
Document dmr = new Document();
besApi.getDMRDocument(
resourceID,
qp,
xmlBase,
dmr);
dmr.getRootElement().setAttribute("dataset_id",resourceID);
String currentDir = System.getProperty("user.dir");
log.debug("Cached working directory: "+currentDir);
String xslDir = new PathBuilder(_systemPath).pathAppend("nciso").pathAppend("xsl").toString();
log.debug("Changing working directory to "+ xslDir);
System.setProperty("user.dir",xslDir);
try {
String xsltDocName = "ddx2iso.xsl";
// This Transformer class is an attempt at making the use of the saxon-9 API
// a little simpler to use. It makes it easy to set input parameters for the stylesheet.
// See the source code for opendap.xml.Transformer for more.
Transformer transformer = new Transformer(xsltDocName);
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(new JDOMSource(dmr), os);
os.flush();
log.info("Sent {}", getServiceTitle());
}
finally {
log.debug("Restoring working directory to "+ currentDir);
System.setProperty("user.dir",currentDir);
}
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:72,代码来源:IsoDMR.java
示例12: xsltDir
import org.jdom.transform.JDOMSource; //导入依赖的package包/类
/**
* ************************************************************************
* Handler for OPeNDAP directory requests. Returns an html document
* with a list of all datasets on this server with links to their
* DDS, DAS, Information, and HTML responses. Talks to the BES to get the
* information.
*
* @param request The <code>HttpServletRequest</code> from the client.
* @param response The <code>HttpServletResponse</code> for the client.
* @throws Exception when things go poorly.
* @see opendap.coreServlet.ReqInfo
*/
public void xsltDir(HttpServletRequest request,
HttpServletResponse response)
throws Exception {
log.info("sendDIR() request = " + request);
// String context = request.getContextPath();
response.setContentType("text/html");
response.setHeader("Content-Description", "dap_directory");
response.setHeader("Cache-Control", "max-age=0, no-cache, no-store");
//Cache-Control: max-age=0, no-cache, no-store
// response.setStatus(HttpServletResponse.SC_OK);
Request oreq = new Request(null,request);
String collectionName = getCollectionName(oreq);
XMLOutputter xmlo = new XMLOutputter(Format.getPrettyFormat());
Document showCatalogDoc = new Document();
_besApi.getBesCatalog(collectionName, showCatalogDoc);
log.debug("Catalog from BES:\n"+xmlo.outputString(showCatalogDoc));
JDOMSource besCatalog = new JDOMSource(showCatalogDoc);
String xsltDoc = systemPath + "/xsl/dap4Contents.xsl";
if(BesDapDispatcher.useDAP2ResourceUrlResponse())
xsltDoc = systemPath + "/xsl/contents.xsl";
Transformer transformer = new Transformer(xsltDoc);
transformer.setParameter("dapService",oreq.getServiceLocalId());
transformer.setParameter("docsService",oreq.getDocsServiceLocalID());
transformer.setParameter("viewersService", ViewersServlet.getServiceId());
if(BesDapDispatcher.allowDirectDataSourceAccess())
transformer.setParameter("allowDirectDataSourceAccess","true");
AuthenticationControls.setLoginParameters(transformer,request);
// Transform the BES showCatalog response into a HTML page for the browser
transformer.transform(besCatalog, response.getOutputStream());
// transformer.transform(besCatalog, System.out);
}
开发者ID:OPENDAP,项目名称:olfs,代码行数:71,代码来源:DirectoryDispatchHandler.java
注:本文中的org.jdom.transform.JDOMSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论