当前位置: 首页>>代码示例>>Java>>正文


Java URIResolver类代码示例

本文整理汇总了Java中javax.xml.transform.URIResolver的典型用法代码示例。如果您正苦于以下问题:Java URIResolver类的具体用法?Java URIResolver怎么用?Java URIResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


URIResolver类属于javax.xml.transform包,在下文中一共展示了URIResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTransform

import javax.xml.transform.URIResolver; //导入依赖的package包/类
/**
 * Performs the XSLT transformation.
 */
private String doTransform(final Transformer transformer, final Source input, final URIResolver resolver)
{
	final StringWriter writer = new StringWriter();
	final StreamResult output = new StreamResult(writer);

	if( resolver != null )
	{
		transformer.setURIResolver(resolver);
	}

	try
	{
		transformer.transform(input, output);
	}
	catch( final TransformerException ex )
	{
		throw new RuntimeException("Error transforming XSLT", ex);
	}

	return writer.toString();
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:XsltServiceImpl.java

示例2: readObject

import javax.xml.transform.URIResolver; //导入依赖的package包/类
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    is.defaultReadObject();
    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:TemplatesImpl.java

示例3: initialize

import javax.xml.transform.URIResolver; //导入依赖的package包/类
public void initialize(String pipelineURI, String uriResolverClassName, String entityResolverClassName) {
	try{
		if (uriResolverClassName != null && uriResolverClassName.trim().length()!=0)
			theURIResolver = (URIResolver) getClass().getClassLoader().loadClass(uriResolverClassName).newInstance();
		else
			theURIResolver = null;
		if (entityResolverClassName != null && entityResolverClassName.trim().length()!=0)
			theEntityResolver = (EntityResolver) getClass().getClassLoader().loadClass(entityResolverClassName).newInstance();
		else
			theEntityResolver = null;
		if (pipelineURI != null && pipelineURI.trim().length()!=0)
			thePipelineURI = pipelineURI;
		else
			thePipelineURI = null;
	}
	catch (Throwable t){
		compilationErrors.clear();
		compilationErrors.add(new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_ERROR, "Error initializing adapter: "+t.getMessage()));
		dumpStackTrace(t);
	}
}
 
开发者ID:xml-project,项目名称:support-for-xmleditor,代码行数:22,代码来源:Adapter.java

示例4: getFactory

import javax.xml.transform.URIResolver; //导入依赖的package包/类
TransformerFactory getFactory() throws Exception {
    if (fac == null) {
        fac = TransformerFactory.newInstance();
        fac.setURIResolver(new URIResolver() {
            public Source resolve(String href, String base) throws TransformerException {
                try {
                    return new StreamSource(asl2xml.class.getResource("/xml/" + href).openStream());
                } catch (Exception e) {
                    System.err.println("Error - " + href + "-" + base);
                    e.printStackTrace();
                    return null;
                }
            }
        });
    }
    return fac;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:asl2xml.java

示例5: getTransformerFactory

import javax.xml.transform.URIResolver; //导入依赖的package包/类
/**
 * Returns an instance of TransformerFactory with either a custom URIResolver
 * or Catalog.
 *
 * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set
 * through the factory
 * @param useCatalog the value of USE_CATALOG
 * @param catalog a catalog
 * @param resolver a custom resolver
 * @return an instance of TransformerFactory
 * @throws Exception
 */
TransformerFactory getTransformerFactory(boolean setUseCatalog, boolean useCatalog,
        String catalog, URIResolver resolver)
        throws Exception {

    TransformerFactory factory = TransformerFactory.newInstance();
    if (setUseCatalog) {
        factory.setFeature(XMLConstants.USE_CATALOG, useCatalog);
    }
    if (catalog != null) {
        factory.setAttribute(CatalogFeatures.Feature.FILES.getPropertyName(), catalog);
    }

    // use resolver or catalog if resolver = null
    if (resolver != null) {
        factory.setURIResolver(resolver);
    }

    return factory;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:CatalogSupportBase.java

示例6: getCustomURIResolver

import javax.xml.transform.URIResolver; //导入依赖的package包/类
private URIResolver getCustomURIResolver() {
    return new URIResolver() {

        @Override
        public Source resolve(String href, String base) throws TransformerException {
            if (href.equals("org/apache/camel/component/xslt/include_not_existing_resource.xsl")) {
                try {
                    InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, href);
                    return new StreamSource(is);
                } catch (Exception e) {
                    throw new TransformerException(e);
                }
            }

            Source constantResult = new StreamSource(new ByteArrayInputStream(EXPECTED_XML_CONSTANT.getBytes()));
            return constantResult;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:XsltCustomizeURIResolverTest.java

示例7: getURIResolverMapping

import javax.xml.transform.URIResolver; //导入依赖的package包/类
public Map<String, URIResolver> getURIResolverMapping() {
    Map<String, String> props = MCRConfiguration.instance().getPropertiesMap(CONFIG_PREFIX + "ModuleResolver.");
    if (props.isEmpty()) {
        return new HashMap<>();
    }
    Map<String, URIResolver> map = new HashMap<>();
    for (Entry<String, String> entry : props.entrySet()) {
        try {
            String scheme = entry.getKey();
            scheme = scheme.substring(scheme.lastIndexOf('.') + 1);
            LOGGER.debug("Adding Resolver {} for URI scheme {}", entry.getValue(), scheme);
            map.put(scheme, MCRConfiguration.instance().getInstanceOf(entry.getKey()));
        } catch (Exception e) {
            LOGGER.error("Cannot instantiate {} for URI scheme {}", entry.getValue(), entry.getKey());
            throw new MCRException(
                "Cannot instantiate " + entry.getValue() + " for URI scheme " + entry.getKey(), e);
        }
    }
    return map;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:21,代码来源:MCRURIResolver.java

示例8: extractFactModel

import javax.xml.transform.URIResolver; //导入依赖的package包/类
@Override
public String extractFactModel(String document, String enforcementPolicies) {

    try {
        final String xslUrl = Thread.currentThread().getContextClassLoader()
                .getResource(EXTRACT_CLINICAL_FACTS_XSL).toString();
        final String xacmlResult = enforcementPolicies.replace("<xacmlReslt>",
                "<xacmlReslt xmlns:\"urn:hl7-org:v3\">");
        final Optional<URIResolver> uriResolver = Optional
                .of(new StringURIResolver()
                        .put(PARAM_XACML_RESULT, xacmlResult));
        String factModel = xmlTransformer.transform(document, xslUrl,
                Optional.empty(), uriResolver);

        factModel = factModel
                .replace(
                        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>",
                        "");
        logger.debug("FactModel:");
        logger.debug(factModel);
        return factModel;
    } catch (final Exception e) {
        throw new DocumentSegmentationException(e.getMessage(), e);
    }
}
 
开发者ID:bhits,项目名称:dss-api,代码行数:26,代码来源:DocumentFactModelExtractorImpl.java

示例9: tagDocument

import javax.xml.transform.URIResolver; //导入依赖的package包/类
@Override
public String tagDocument(String document, String executionResponseContainer) {
    try {
        executionResponseContainer = executionResponseContainer.replace(
                "<ruleExecutionContainer>",
                "<ruleExecutionContainer xmlns=\"urn:hl7-org:v3\">");
        final String xslUrl = Thread.currentThread().getContextClassLoader()
                .getResource(TAG_XSL).toString();
        final StringURIResolver stringURIResolver = new StringURIResolver();
        stringURIResolver.put(
                URI_RESOLVER_HREF_RULE_EXECUTION_RESPONSE_CONTAINER,
                executionResponseContainer);
        final String additionalCustomSections = marshaller.marshal(documentTaggerConfig.getAdditionalSectionsAsCustomSectionList());
        stringURIResolver.put("customSectionList", additionalCustomSections);
        final Optional<URIResolver> uriResolver = Optional
                .of(stringURIResolver);
        final String taggedDocument = xmlTransformer.transform(document,
                xslUrl, Optional.empty(), uriResolver);
        logger.debug("Tagged Document:");
        logger.debug(taggedDocument);
        return taggedDocument;
    } catch (final Exception e) {
        throw new DocumentSegmentationException(e.getMessage(), e);
    }
}
 
开发者ID:bhits,项目名称:dss-api,代码行数:26,代码来源:DocumentTaggerImpl.java

示例10: getTransformerFactory

import javax.xml.transform.URIResolver; //导入依赖的package包/类
public static TransformerFactory getTransformerFactory() {
    if (tFactory == null) {
        tFactory = TransformerFactory.newInstance();
        tFactory.setURIResolver(new URIResolver() {
            public Source resolve(String href, String base) throws TransformerException {
                try {
                    return DOMUtils.getXSL(href);
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
                }
            }
        });
    }
    return tFactory;
}
 
开发者ID:moise-lang,项目名称:moise,代码行数:17,代码来源:DOMUtils.java

示例11: resolve

import javax.xml.transform.URIResolver; //导入依赖的package包/类
public TransformerHandler resolve (final String method,
                                   final String href,
                                   final String base,
                                   final URIResolver uriResolver,
                                   final ErrorListener errorListener,
                                   final Hashtable <String, Object> params) throws SAXException
{
  if (METHOD.equals (method))
  {
    if (href != null)
      throw new SAXException ("Specification of an external source '" + href + "' not allowed for " + method);
    skipUri = String.valueOf (params.get ("uri"));
    return this;
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-stx,代码行数:17,代码来源:NSFilter.java

示例12: transform

import javax.xml.transform.URIResolver; //导入依赖的package包/类
@Override
public String transform(final FileHandle handle, final String xslt, final Reader input, final URIResolver resolver)
{
	StreamSource source = null;
	try
	{
		source = getSource(input);
		return transformFromFileHandle(handle, xslt, source, resolver, false);
	}
	finally
	{
		closeSource(source);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:XsltServiceImpl.java

示例13: readObject

import javax.xml.transform.URIResolver; //导入依赖的package包/类
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
@SuppressWarnings("unchecked")
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = is.readFields();
    _name = (String)gf.get("_name", null);
    _bytecodes = (byte[][])gf.get("_bytecodes", null);
    _class = (Class[])gf.get("_class", null);
    _transletIndex = gf.get("_transletIndex", -1);

    _outputProperties = (Properties)gf.get("_outputProperties", null);
    _indentNumber = gf.get("_indentNumber", 0);

    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:TemplatesImpl.java

示例14: testXSLImportA

import javax.xml.transform.URIResolver; //导入依赖的package包/类
@Test(dataProvider = "data_XSLA")
public void testXSLImportA(boolean setUseCatalog, boolean useCatalog, String catalog,
        SAXSource xsl, StreamSource xml, URIResolver resolver, String expected)
        throws Exception {

    testXSLImport(setUseCatalog, useCatalog, catalog, xsl, xml, resolver, expected);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:CatalogSupport4.java

示例15: getDataXSL

import javax.xml.transform.URIResolver; //导入依赖的package包/类
@DataProvider(name = "data_XSLA")
public Object[][] getDataXSL() {
    // XSLInclude.xsl has one import XSLImport_html.xsl and two includes,
    // XSLInclude_header.xsl and XSLInclude_footer.xsl;
    String[] hrefs = {"XSLImport_html.xsl", "XSLInclude_header.xsl", "XSLInclude_footer.xsl"};
    Source[] returnValues = {new StreamSource(xsl_import_html),
                    new StreamSource(xsl_include_header),
                    new StreamSource(xsl_include_footer)};
    URIResolver resolver = new XslResolver(hrefs, returnValues);
    SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD)));
    StreamSource xmlSourceDTD = new StreamSource(new StringReader(xml_xslDTD));

    String[] hrefs1 = {"pathto/DocFunc2.xml"};
    Source[] returnValues1 = {new StreamSource(xml_doc2)};
    URIResolver docResolver = new XslResolver(hrefs1, returnValues1);
    SAXSource xslDocSource = new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString()));
    StreamSource xmlDocSource = new StreamSource(new File(xml_doc));
    return new Object[][]{
        // for resolving DTD, import and include in xsl
        {false, true, xml_catalog, xslSourceDTD, xmlSourceDTD, null, ""},
        {false, true, xml_bogus_catalog, new SAXSource(new InputSource(new StringReader(xsl_include))),
            new StreamSource(new StringReader(xml_xsl)), resolver, ""},
        {true, true, xml_bogus_catalog, new SAXSource(new InputSource(new StringReader(xsl_include))),
            new StreamSource(new StringReader(xml_xsl)), resolver, ""},
        // for resolving reference by the document function
        {false, true, xml_catalog, xslDocSource, xmlDocSource, null, "Resolved by a catalog"},
        {false, true, xml_bogus_catalog, xslDocSource, xmlDocSource, docResolver, "Resolved by a resolver"},
        {true, true, xml_bogus_catalog, xslDocSource, xmlDocSource, docResolver, "Resolved by a resolver"}
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:CatalogSupport.java


注:本文中的javax.xml.transform.URIResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。