當前位置: 首頁>>代碼示例>>Java>>正文


Java LSInput類代碼示例

本文整理匯總了Java中org.w3c.dom.ls.LSInput的典型用法代碼示例。如果您正苦於以下問題:Java LSInput類的具體用法?Java LSInput怎麽用?Java LSInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LSInput類屬於org.w3c.dom.ls包,在下文中一共展示了LSInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的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

示例2: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    InputSource is = resolveEntity(publicId, systemId);

    if (is != null && !is.isEmpty()) {
        return new LSInputImpl(is.getSystemId());
    }

    GroupEntry.ResolveType resolveType = ((CatalogImpl) catalog).getResolve();
    switch (resolveType) {
        case IGNORE:
            return null;
        case STRICT:
            CatalogMessages.reportError(CatalogMessages.ERR_NO_MATCH,
                    new Object[]{publicId, systemId});
    }

    //no action, allow the parser to continue
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:CatalogResolverImpl.java

示例3: testExternalEncoding

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Test
public void testExternalEncoding() {

    try {
        LSInput src = null;
        LSParser dp = null;

        src = createLSInputEncoding();
        dp = createLSParser();

        src.setEncoding("UTF-16");
        Document doc = dp.parse(src);
        Assert.assertTrue("encodingXML".equals(doc.getDocumentElement().getNodeName()), "XML document is not parsed correctly");

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:Bug6355326.java

示例4: testLSInputParsingByteStream

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DocumentLSTest.java

示例5: testLSInputParsingString

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Test
public void testLSInputParsingString() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    String xml = "<?xml version='1.0'?><test>runDocumentLS_Q6</test>";

    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSSerializer domSerializer = impl.createLSSerializer();
    // turn off xml decl in serialized string for comparison
    domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
    LSInput src = impl.createLSInput();
    src.setStringData(xml);
    assertEquals(src.getStringData(), xml);

    Document doc = domParser.parse(src);
    String result = domSerializer.writeToString(doc);

    assertEquals(result, "<test>runDocumentLS_Q6</test>");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:DocumentLSTest.java

示例6: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    InputStream stream = null;
    try {
        File file = new File(xsdDir, systemId);
        stream = new FileInputStream(file);
        LSInputImpl input = new LSInputImpl();
        input.setPublicId(publicId);
        input.setSystemId(systemId);
        input.setBaseURI(baseURI);
        input.setCharacterStream(new InputStreamReader(stream));
        return input;
    } catch (FileNotFoundException e) {
        return null;
    }
}
 
開發者ID:NLCR,項目名稱:komplexni-validator,代碼行數:17,代碼來源:XsdImportsResourceResolver.java

示例7: parse

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:DomDocumentBuilder.java

示例8: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId,
		String baseURI) {
	LOG.debug("resolve resource");
	LOG.debug("type: " + type);
	LOG.debug("namespace URI: " + namespaceURI);
	LOG.debug("publicId: " + publicId);
	LOG.debug("systemId: " + systemId);
	LOG.debug("base URI: " + baseURI);
	if ("http://uri.etsi.org/01903/v1.3.2#".equals(namespaceURI)) {
		return new LocalLSInput(publicId, systemId, baseURI, "/XAdES.xsd");
	}
	if ("http://www.w3.org/2000/09/xmldsig#".equals(namespaceURI)) {
		return new LocalLSInput(publicId, systemId, baseURI, "/xmldsig-core-schema.xsd");
	}
	throw new RuntimeException("unsupported resource: " + namespaceURI);
}
 
開發者ID:e-Contract,項目名稱:eid-applet,代碼行數:17,代碼來源:XAdESSignatureFacetTest.java

示例9: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Override
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
        String location = map.get(systemId);
//        System.out.printf("\ntype: %s\nnsURI: %s\npublicId: %s\nsystemId: %s\nbaseURI: %s\n",
//                type, namespaceURI, publicId, systemId, baseURI);
        if (location == null) {
            for (Class<?> base : bases) {
                URL resource = base.getResource(systemId);
                if (resource != null) {
                    systemId = resource.toExternalForm();
                    break;
                }
            }
        }
        LSInput input = dls.createLSInput();
        input.setSystemId(systemId);
//        System.out.println("Real system ID: " + systemId);
        return input;
    }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:20,代碼來源:SimpleLSResourceResolver.java

示例10: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
public LSInput resolveResource(String type, String namespaceURI,
                               String publicId, String systemId, String baseURI) {
    try {
        URL url = new URL(namespaceURI + '/' + systemId);
        String content = cache.get(url);
        if (content == null) {
            content = streamToString(new URL(namespaceURI + '/' + systemId).openStream());
            if (content != null) cache.put(url, content);
        }
        return new Input(publicId, systemId, stringToStream(content));
    }
    catch (MalformedURLException mue) {
        mue.printStackTrace();
        return null;
    }
    catch (IOException ioe) {
        ioe.printStackTrace();
        return null;
    }
}
 
開發者ID:yawlfoundation,項目名稱:yawl,代碼行數:21,代碼來源:ResourceResolver.java

示例11: testInstanceResourceResolver

import org.w3c.dom.ls.LSInput; //導入依賴的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

示例12: testSchemaResourceResolver

import org.w3c.dom.ls.LSInput; //導入依賴的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

示例13: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Override
		public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) {
			if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) {
				LSInputImpl input = new LSInputImpl();
				input.setPublicId(thePublicId);
				input.setSystemId(theSystemId);
				input.setBaseURI(theBaseURI);
//				String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId;
				String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId;

				ourLog.debug("Loading referenced schema file: " + pathToBase);

				InputStream baseIs = FhirValidator.class.getClassLoader().getResourceAsStream(pathToBase);
				if (baseIs == null) {
					throw new InternalErrorException("Schema file not found: " + pathToBase);
				}

				input.setByteStream(baseIs);

				return input;

			}

			throw new ConfigurationException("Unknown schema: " + theSystemId);
		}
 
開發者ID:gajen0981,項目名稱:FHIR-Server,代碼行數:26,代碼來源:SchemaBaseValidator.java

示例14: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    String schemaLocation = _descriptor.getSchemaLocation(namespaceURI, systemId);
    if (schemaLocation == null && baseURI != null && baseURI.endsWith(".dtd")) {
        String schema = baseURI.substring(0, baseURI.lastIndexOf('/')+1) + systemId;
        schemaLocation = _descriptor.getSchemaLocation(null, schema);
    }
    if (schemaLocation != null) {
        try {
            String xsd = new StringPuller().pull(schemaLocation, getClass());
            if (xsd != null) {
                return new DescriptorLSInput(xsd, publicId, systemId, baseURI);
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
    return null;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:19,代碼來源:Descriptor.java

示例15: resolveResource

import org.w3c.dom.ls.LSInput; //導入依賴的package包/類
@Override
public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) {
	if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) {
		LSInputImpl input = new LSInputImpl();
		input.setPublicId(thePublicId);
		input.setSystemId(theSystemId);
		input.setBaseURI(theBaseURI);
		// String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId;
		String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId;

		ourLog.debug("Loading referenced schema file: " + pathToBase);

		InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
		if (baseIs == null) {
			IOUtils.closeQuietly(baseIs);
			throw new InternalErrorException("Schema file not found: " + pathToBase);
		}

		input.setByteStream(baseIs);
		//FIXME resource leak
		return input;

	}

	throw new ConfigurationException("Unknown schema: " + theSystemId);
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:27,代碼來源:SchemaBaseValidator.java


注:本文中的org.w3c.dom.ls.LSInput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。