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


Java LSInput.setSystemId方法代碼示例

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


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

示例1: 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

示例2: parse

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public Document parse(InputStream in, String systemId)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  input.setSystemId(systemId);
  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,代碼行數:20,代碼來源:DomDocumentBuilder.java

示例3: 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

示例4: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
	
	try {
		InputStream inputStream = new URL(new URL(baseURI), systemId).openStream();
		
		LSInput retval = new DefaultLSInput();
		retval.setByteStream(inputStream);
		retval.setBaseURI(baseURI);
		retval.setSystemId(systemId);
		retval.setPublicId(publicId);
		
		return retval;
	} catch(IOException e) {
		return null;
	}
}
 
開發者ID:IDgis,項目名稱:geo-publisher,代碼行數:18,代碼來源:DefaultLSResourceResolver.java

示例5: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public LSInput resolveResource(String type, 
                               String namespaceURI, 
                               String publicId, 
                               String systemId, 
                               String baseURI) {
    
     LSInput lsi = mDelegate.resolveResource(type, namespaceURI, publicId, systemId, baseURI);

     if (lsi == null) {
         //if we can not get an input from catalog, then it could that
         //there as a schema in types section which refer to schema compoment from other inline schema
         //so we try to check in other inline schema.
         WSDLSchema schema = findSchema(namespaceURI);
         if(schema != null) {
             Reader in = createInlineSchemaSource(mWsdlText, mWsdlPrefixes, mWsdlLinePositions, schema);
             if(in != null) {
                 //create LSInput object
                 DOMImplementation domImpl = null;
                 try {
                     domImpl =  DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
                 } catch (ParserConfigurationException ex) {
                     Logger.getLogger(getClass().getName()).log(Level.SEVERE, "resolveResource", ex); //NOI18N
                     return null;
                 }

                 DOMImplementationLS dols = (DOMImplementationLS) domImpl.getFeature("LS","3.0");
                 lsi = dols.createLSInput();
                 lsi.setCharacterStream(in);

                 if(mWsdlSystemId != null) {
                     lsi.setSystemId(mWsdlSystemId);
                 }
                 return lsi;  
             }
         }
     }
     return lsi;                      
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:WSDLInlineSchemaValidator.java

示例6: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
{
    LOGGER.debug("==== Resolving '" + type + "' '" + namespaceURI + "' '" + publicId + "' '" + systemId + "' '" +
            baseURI + "'");
    LSInput lsInput = domImplementationLS.createLSInput();
    InputStream is = getXSDStream(systemId);
    if(is==null)return null;                
    lsInput.setByteStream(is);
    lsInput.setSystemId(systemId);
    lsInput.setBaseURI(baseURI);
    lsInput.setPublicId(publicId);
    LOGGER.debug("==== Resolved ====");
    return lsInput;            
}
 
開發者ID:ArticulatedSocialAgentsPlatform,項目名稱:HmiCore,代碼行數:15,代碼來源:XSDValidationTest.java

示例7: parseURI

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public Document parseURI(String uri)
  throws DOMException, LSException
{
  LSInput input = new DomLSInput();
  input.setSystemId(uri);
  return parse(input);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:8,代碼來源:DomLSParser.java

示例8: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public LSInput resolveResource( String type, String namespaceURI, String publicId, String systemId, String baseURI )
{
    String resourceName = local.getProperty( systemId );
    if( resourceName == null )
    {
        System.out.println( "type: " + type );
        System.out.println( "namespaceURI: " + namespaceURI );
        System.out.println( "publicId: " + publicId );
        System.out.println( "systemId: " + systemId );
        System.out.println( "baseURI: " + baseURI );
        return null;
    }

    InputStream resource = getClass().getClassLoader().getResourceAsStream( resourceName );
    LSInput input;
    try
    {
        input = getLSInput();
    }
    catch( Exception e )
    {
        throw new UnsupportedOperationException( "Internal problem. Please report to [email protected] mailing list.", e  );
    }
    input.setBaseURI( baseURI );
    input.setByteStream( resource );
    input.setPublicId( publicId );
    input.setSystemId( systemId );
    return input;
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:30,代碼來源:QuikitResolver.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 = URL_MAP.get(systemId);
    if (location == null) {
        throw new IllegalStateException("Unable to find mapping for:" + systemId);
    }
    InputStream is = this.getClass().getResourceAsStream(location);
    LSInput input = dls.createLSInput();
    input.setByteStream(is);
    input.setPublicId(publicId);
    input.setSystemId(systemId);
    return input;
}
 
開發者ID:proarc,項目名稱:proarc,代碼行數:14,代碼來源:MetsLSResolver.java

示例10: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
@Override
public LSInput resolveResource(String xiType,
                               String xiNamespaceURI,
                               String xiPublicId,
                               String xiSystemId,
                               String xiBaseURI)
{
  try
  {
    LSInput lret;

    String lFilename = sCatalog.get(xiNamespaceURI);
    if (lFilename != null)
    {
      mProgress.log("Reading " + xiNamespaceURI + " from local cache: " + lFilename);
      lret = new Input();
      lret.setByteStream(new FileInputStream(new File(sSchemaRoot, lFilename)));
    }
    else if (mIsRetrievalEnabled)
    {
      mProgress.log("Attempting to retrieve " + xiNamespaceURI + " from " + xiSystemId);
      lret = new Input();
      lret.setSystemId(xiSystemId);
    }
    else
    {
      String lType = XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(xiType) ?
                                                         "schema" : xiType;
      throw new RuntimeException("Unable to retrieve " + lType +
        " document for namespace " + xiNamespaceURI + " with public ID " +
          xiPublicId + " and system ID " + xiSystemId);
    }

    return lret;
  }
  catch (IOException e)
  {
    throw new RuntimeException(e);
  }
}
 
開發者ID:kw217,項目名稱:sax2j,代碼行數:41,代碼來源:Resolver.java

示例11: resolveResource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
         * Allow the application to resolve external resources.
         */
        public LSInput resolveResource(final String type, final String namespaceURI, final String publicId, final String systemId, final String baseURI) {
//            System.out.println("\n>> Resolving "  +  "\n"   
//                              + "TYPE: "  + type +  "\n"   
//                              + "NAMESPACE_URI: "  + namespaceURI +  "\n"    
//                              + "PUBLIC_ID: "  + publicId +  "\n"   
//                              + "SYSTEM_ID: "  + systemId +  "\n"   
//                              + "BASE_URI: "  + baseURI +  "\n" );  

            final LSInput lsInput = new LSInputImpl();

            // In all Java EE schema xsd files, the <xsd:include schemaLocation=../> always reference to a relative path. 
            // so the systemId here will be the xsd file name.
            final URL schemaURL = JaxbJavaee.getSchemaURL(systemId);

            InputStream is = null;
            if (schemaURL != null) {
                try {
                    is = schemaURL.openStream();
                } catch (final IOException e) {
                    //should not happen
                    throw new RuntimeException(e);
                }
            }

            lsInput.setSystemId(systemId);
            lsInput.setByteStream(is);

            return lsInput;
        }
 
開發者ID:apache,項目名稱:tomee,代碼行數:33,代碼來源:JaxbJavaee.java

示例12: newInputSource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public InputSource newInputSource(String filename) throws Exception {
    // Create DOMImplementationLS, and DOM L3 LSParser
    DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
    DocumentBuilder bldr = fact.newDocumentBuilder();
    DOMImplementationLS impl = (DOMImplementationLS) bldr.getDOMImplementation();
    LSParser domparser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    domparser.setFilter(new MyDOMBuilderFilter());

    // Parse the xml document to create the DOM Document using
    // the DOM L3 LSParser and a LSInput (formerly LSInputSource)
    Document doc = null;
    LSInput src = impl.createLSInput();
    // register the input file with the input source...
    String systemId = filenameToURL(filename);
    src.setSystemId(systemId);
    try (Reader reader = new FileReader(filename)) {
        src.setCharacterStream(reader);
        src.setEncoding("UTF-8");
        doc = domparser.parse(src);
    }

    // Use DOM L3 LSSerializer (previously called a DOMWriter)
    // to serialize the xml doc DOM to a file stream.
    String tmpCatalog = Files.createTempFile(Paths.get(USER_DIR), "catalog.xml", null).toString();

    LSSerializer domserializer = impl.createLSSerializer();
    domserializer.setFilter(new MyDOMWriterFilter());
    domserializer.getNewLine();
    DOMConfiguration config = domserializer.getDomConfig();
    config.setParameter("xml-declaration", Boolean.TRUE);
    String result = domserializer.writeToString(doc);
    try (FileWriter os = new FileWriter(tmpCatalog, false)) {
        os.write(result);
        os.flush();
    }

    // Return the Input Source created from the Serialized DOM L3 Document.
    InputSource catsrc = new InputSource(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(tmpCatalog)))));
    catsrc.setSystemId(systemId);
    return catsrc;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:42,代碼來源:DOML3InputSourceFactoryImpl.java

示例13: newInputSource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
public InputSource newInputSource(String filename) throws Exception {
    // Create DOMImplementationLS, and DOM L3 LSParser
    DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
    DocumentBuilder bldr = fact.newDocumentBuilder();
    DOMImplementationLS impl = (DOMImplementationLS) bldr.getDOMImplementation();
    LSParser domparser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    domparser.setFilter(new MyDOMBuilderFilter());

    // Parse the xml document to create the DOM Document using
    // the DOM L3 LSParser and a LSInput (formerly LSInputSource)
    Document doc = null;
    LSInput src = impl.createLSInput();
    // register the input file with the input source...
    String systemId = filenameToURL(filename);
    src.setSystemId(systemId);
    try (Reader reader = new FileReader(filename)) {
        src.setCharacterStream(reader);
        src.setEncoding("UTF-8");
        doc = domparser.parse(src);
    }

    // Use DOM L3 LSSerializer (previously called a DOMWriter)
    // to serialize the xml doc DOM to a file stream.
    String tmpCatalog = Files.createTempFile(Paths.get("").toAbsolutePath(), "catalog.xml", null).toString();

    LSSerializer domserializer = impl.createLSSerializer();
    domserializer.setFilter(new MyDOMWriterFilter());
    domserializer.getNewLine();
    DOMConfiguration config = domserializer.getDomConfig();
    config.setParameter("xml-declaration", Boolean.TRUE);
    String result = domserializer.writeToString(doc);
    try (FileWriter os = new FileWriter(tmpCatalog, false)) {
        os.write(result);
        os.flush();
    }

    // Return the Input Source created from the Serialized DOM L3 Document.
    InputSource catsrc = new InputSource(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(tmpCatalog)))));
    catsrc.setSystemId(systemId);
    return catsrc;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:42,代碼來源:DOML3InputSourceFactoryImpl.java


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