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


Java LSResourceResolver类代码示例

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


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

示例1: validate

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
private void validate(WSDLModel model, 
                      Source saxSource, 
                      XsdBasedValidator.Handler handler,
                      LSResourceResolver resolver) {
    try {
        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

        if (resolver != null) {
            sf.setResourceResolver(resolver);
        }
        sf.setErrorHandler(handler);

        if (saxSource == null) {
            return;
        }
        sf.newSchema(saxSource);
    } catch(SAXException sax) {
        //already processed by handler
    } catch(Exception ex) {
        handler.logValidationErrors(Validator.ResultType.ERROR, ex.getMessage());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:WSDLInlineSchemaValidator.java

示例2: resolveResource

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    LSInput input = null;
    
    Iterator<ValidatorSchemaFactory> it = mExtSchemaFactories.iterator();
    while(it.hasNext()) {
        ValidatorSchemaFactory fac = it.next();
        LSResourceResolver resolver = fac.getLSResourceResolver();
        if(resolver != null) {
            input = resolver.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
            if(input != null) {
               break;
            }
        }
    }
    
    return input;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:WSDLSchemaValidator.java

示例3: getCompiledSchema

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
/**
 * Subclasses can use this to get a compiled schema object.
 * @param schemas Input stream of schemas.
 * @param lsResourceResolver  resolver can be supplied optionally. Otherwise pass null.
 * @return  Compiled Schema object.
 */
protected Schema getCompiledSchema(InputStream[] schemas,
        LSResourceResolver lsResourceResolver) {
    
    Schema schema = null;
    // Convert InputStream[] to StreamSource[]
    StreamSource[] schemaStreamSources = new StreamSource[schemas.length];
    for(int index1=0 ; index1<schemas.length ; index1++)
        schemaStreamSources[index1] = new StreamSource(schemas[index1]);
    
    // Create a compiled Schema object.
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    schemaFactory.setResourceResolver(lsResourceResolver);
    try {
        schema = schemaFactory.newSchema(schemaStreamSources);            
    } catch(SAXException ex) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "getCompiledSchema", ex);
    } 
    
    return schema;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:XsdBasedValidator.java

示例4: testValidation

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
public void testValidation(boolean setUseCatalog, boolean useCatalog, String catalog,
        String xsd, LSResourceResolver resolver)
        throws Exception {

    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

    // use resolver or catalog if resolver = null
    if (resolver != null) {
        factory.setResourceResolver(resolver);
    }
    if (setUseCatalog) {
        factory.setFeature(XMLConstants.USE_CATALOG, useCatalog);
    }
    factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog);

    Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd)));
    success("XMLSchema.dtd and datatypes.dtd are resolved.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:CatalogSupportBase.java

示例5: createSchema

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
/**
 * Creates the schema.
 *
 * @param xsdInputStream   the xsd input stream
 * @param resourceResolver the resource resolver
 * @return the schema
 * @throws XmlSchemaFailureException the xml schema failure exception
 */
private Schema createSchema(InputStream xsdInputStream,
                            LSResourceResolver resourceResolver)
        throws XmlSchemaFailureException {
    final SchemaFactory factory = SchemaFactory
            .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    final Source schemaSource = new StreamSource(xsdInputStream);
    if (resourceResolver != null) {
        factory.setResourceResolver(resourceResolver);
    }
    Schema schema;
    try {
        schema = factory.newSchema(schemaSource);
    } catch (final SAXException e) {
        logger.error(e.getMessage());
        throw new XmlSchemaFailureException(e);
    }
    return schema;
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:27,代码来源:XmlValidation.java

示例6: createRouteBuilder

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    // we have to do it here, because we need the context created first
    CatalogManager.getStaticManager().setIgnoreMissingProperties(true);
    CatalogResolver catalogResolver = new CatalogResolver(true);
    URL catalogUrl = ResourceHelper.resolveMandatoryResourceAsUrl(context.getClassResolver(), "org/apache/camel/component/validator/catalog.cat");
    catalogResolver.getCatalog().parseCatalog(catalogUrl);
    LSResourceResolver resourceResolver = new CatalogLSResourceResolver(catalogResolver);
    JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
    registry.bind("resourceResolver", resourceResolver);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
                .doTry()
                    .to("validator:org/apache/camel/component/validator/report.xsd?resourceResolver=#resourceResolver")
                    .to("mock:valid")
                .doCatch(ValidationException.class)
                    .to("mock:invalid")
                .doFinally()
                    .to("mock:finally")
                .end();
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:ValidatorWithResourceResolverRouteTest.java

示例7: testInstanceResourceResolver

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Test
public void testInstanceResourceResolver() throws SAXException, IOException {
  SchemaFactory f = factory();
  Validator v = f.newSchema(charStreamSource(element("doc", element("inner")))).newValidator();
  Assert.assertNull(v.getResourceResolver());
  LSResourceResolver rr = new LSResourceResolver() {
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
      // In Java 5 Xerces absolutized the systemId relative to the current directory
      int slashIndex = systemId.lastIndexOf('/');
      if (slashIndex >= 0)
        systemId = systemId.substring(slashIndex + 1);
      Assert.assertEquals(systemId, "e.xml");
      Assert.assertEquals(type, "http://www.w3.org/TR/REC-xml");
      LSInput in = new LSInputImpl();
      in.setStringData("<inner/>");
      return in;
    }
  };
  v.setResourceResolver(rr);
  Assert.assertSame(v.getResourceResolver(), rr);
  v.validate(charStreamSource("<!DOCTYPE doc [ <!ENTITY e SYSTEM 'e.xml'> ]><doc>&e;</doc>"));
}
 
开发者ID:relaxng,项目名称:jing-trang,代码行数:23,代码来源:SchemaFactoryImplTest.java

示例8: testSchemaResourceResolver

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Test
public void testSchemaResourceResolver() throws SAXException, IOException {
  SchemaFactory f = factory();
  Assert.assertNull(f.getResourceResolver());
  LSResourceResolver rr = new LSResourceResolver() {
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
      Assert.assertEquals(systemId, "myschema");
      Assert.assertEquals(type, getLSType());
      Assert.assertNull(baseURI);
      Assert.assertNull(namespaceURI);
      Assert.assertNull(publicId);
      LSInput in = new LSInputImpl();
      in.setStringData(createSchema("doc"));
      return in;
    }
  };
  f.setResourceResolver(rr);
  Assert.assertSame(f.getResourceResolver(), rr);
  Validator v = f.newSchema(charStreamSource(externalRef("myschema"))).newValidator();
  v.validate(charStreamSource("<doc/>"));
}
 
开发者ID:relaxng,项目名称:jing-trang,代码行数:22,代码来源:SchemaFactoryImplTest.java

示例9: XSParser

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
public XSParser(LSResourceResolver entityResolver, DOMErrorHandler errorHandler){
    System.setProperty(DOMImplementationRegistry.PROPERTY, DOMXSImplementationSourceImpl.class.getName());
    DOMImplementationRegistry registry;
    try{
        registry = DOMImplementationRegistry.newInstance();
    }catch(Exception ex){
        throw new ImpossibleException(ex);
    }
    XSImplementationImpl xsImpl = (XSImplementationImpl)registry.getDOMImplementation("XS-Loader");

    xsLoader = xsImpl.createXSLoader(null);
    DOMConfiguration config = xsLoader.getConfig();
    config.setParameter(Constants.DOM_VALIDATE, Boolean.TRUE);

    if(entityResolver!=null)
        config.setParameter(Constants.DOM_RESOURCE_RESOLVER, entityResolver);

    if(errorHandler!=null)
        config.setParameter(Constants.DOM_ERROR_HANDLER, errorHandler);
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:21,代码来源:XSParser.java

示例10: isValidFacesConfig

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
/**
 * Validates *.faces-config.xml file
 *
 * @param xml
 * @return
 */
private boolean isValidFacesConfig(InputStream xml) {
    try {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        factory.setResourceResolver((LSResourceResolver) DbfFactory.FACES_ENTITY_RESOLVER);

        InputStream xsd = this.getClass().getResourceAsStream(FACES_2_2_XSD);
        Schema schema = factory.newSchema(new StreamSource(xsd));

        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(xml));
        return true;
    } catch (Exception ex) {
        return false;
    }
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:22,代码来源:FacesConfigPopulator.java

示例11: getLSResourceResolver

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
public static LSResourceResolver getLSResourceResolver() throws Exception {
    logger.info("");
    LSResourceResolver resourceResolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceUri,
                String publicId, String systemId, String baseUri) {
            try {
                final InputStream in = GXmlEntity.class.getResource(
                        "/" + systemId).openStream();
                LSInputAdapter adapter = new LSInputAdapter(in);
                return adapter;
            }
            catch (Exception exception) {
                exception.printStackTrace();
                return null;
            }
        }
    };
    return resourceResolver;
}
 
开发者ID:stelian56,项目名称:geometria,代码行数:20,代码来源:GXmlUtils.java

示例12: getLSResourceResolver

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
private static LSResourceResolver getLSResourceResolver() throws Exception {
    logger.info("");
    LSResourceResolver resourceResolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceUri,
                String publicId, String systemId, String baseUri) {
            try {
                final InputStream in = GXmlEntity.class.getResource(
                        "/" + systemId).openStream();
                LSInputAdapter adapter = new LSInputAdapter(in);
                return adapter;
            }
            catch (Exception exception) {
                logger.error(GStringUtils.stackTraceToString(exception));
                return null;
            }
        }
    };
    return resourceResolver;
}
 
开发者ID:stelian56,项目名称:geometria,代码行数:20,代码来源:GXmlUtils.java

示例13: test1

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Test
public void test1() throws Exception {
    String xsd1 = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test1'\n"
            + "        targetNamespace='jaxp13_test1'\n" + "        elementFormDefault='qualified'>\n" + "    <import namespace='jaxp13_test2'/>\n"
            + "    <element name='test'/>\n" + "    <element name='child1'/>\n" + "</schema>\n";

    final NullPointerException EUREKA = new NullPointerException("NewSchema015");

    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    StringReader reader = new StringReader(xsd1);
    StreamSource source = new StreamSource(reader);
    LSResourceResolver resolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
            LSInput input;
            if (namespaceURI != null && namespaceURI.endsWith("jaxp13_test2")) {
                throw EUREKA;
            } else {
                input = null;
            }

            return input;
        }
    };
    schemaFactory.setResourceResolver(resolver);

    try {
        schemaFactory.newSchema(new Source[] { source });
        Assert.fail("NullPointerException was not thrown.");
    } catch (RuntimeException e) {
        if (e != EUREKA)
            throw e;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Bug4997818.java

示例14: testValidationA

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Test(dataProvider = "data_SchemaA")
public void testValidationA(boolean setUseCatalog, boolean useCatalog,
        String catalog, String xsd, LSResourceResolver resolver)
        throws Exception {

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

示例15: testValidatorA

import org.w3c.dom.ls.LSResourceResolver; //导入依赖的package包/类
@Test(dataProvider = "data_ValidatorA")
public void testValidatorA(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog,
        Source source, LSResourceResolver resolver1, LSResourceResolver resolver2,
        String catalog1, String catalog2)
        throws Exception {
    testValidator(setUseCatalog1, setUseCatalog2, useCatalog, source,
            resolver1, resolver2, catalog1, catalog2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CatalogSupport4.java


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