< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BindInfo.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -25,10 +25,12 @@
 
 package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo;
 
 import java.io.FilterWriter;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;

@@ -43,10 +45,11 @@
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
 
 import com.sun.codemodel.internal.JDocComment;
 import com.sun.xml.internal.bind.v2.WellKnownNamespace;
 import com.sun.tools.internal.xjc.SchemaCache;
 import com.sun.tools.internal.xjc.model.CCustomizations;

@@ -57,10 +60,12 @@
 import com.sun.xml.internal.bind.annotation.XmlLocation;
 import com.sun.xml.internal.bind.marshaller.MinimumEscapeHandler;
 import com.sun.xml.internal.xsom.XSComponent;
 
 import org.w3c.dom.Element;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.Locator;
 
 /**
  * Container for customization declarations.
  *

@@ -351,7 +356,112 @@
     }
 
     /**
      * Lazily parsed schema for the binding file.
      */
-    public static final SchemaCache bindingFileSchema = new SchemaCache(BindInfo.class.getResource("binding.xsd"));
+    public static SchemaCache bindingFileSchema =
+            new SchemaCache(
+                    newStreamSource("binding.xsd"),
+                    new LSResourceResolver() {
+                        @Override
+                        public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
+                            // XSOM passes the namespace URI to the publicID parameter.
+                            // we do the same here .
+                            InputStream is = BindInfo.class.getResourceAsStream(systemId);
+                            return new Input(is, publicId, systemId);
+                        }
+                    }
+            );
+
+    private static StreamSource newStreamSource(String systemId) {
+        InputStream is = BindInfo.class.getResourceAsStream(systemId);
+        StreamSource schema = new StreamSource(is);
+        schema.setSystemId(systemId);
+        return schema;
+    }
+
+}
+
+class Input implements LSInput {
+
+    InputStream is;
+    String publicId;
+    String systemId;
+
+    public Input(InputStream is, String publicId, String systemId) {
+        this.is = is;
+        this.publicId = publicId;
+        this.systemId = systemId;
+    }
+
+    @Override
+    public Reader getCharacterStream() {
+        return null;
+    }
+
+    @Override
+    public void setCharacterStream(Reader characterStream) {
+    }
+
+    @Override
+    public InputStream getByteStream() {
+        return is;
+    }
+
+    @Override
+    public void setByteStream(InputStream byteStream) {
+    }
+
+    @Override
+    public String getStringData() {
+        return null;
+    }
+
+    @Override
+    public void setStringData(String stringData) {
+    }
+
+    @Override
+    public String getSystemId() {
+        return systemId;
+    }
+
+    @Override
+    public void setSystemId(String systemId) {
+    }
+
+    @Override
+    public String getPublicId() {
+        return publicId;
+    }
+
+    @Override
+    public void setPublicId(String publicId) {
+    }
+
+    @Override
+    public String getBaseURI() {
+        return null;
+    }
+
+    @Override
+    public void setBaseURI(String baseURI) {
+    }
+
+    @Override
+    public String getEncoding() {
+        return null;
+    }
+
+    @Override
+    public void setEncoding(String encoding) {
+    }
+
+    @Override
+    public boolean getCertifiedText() {
+        return false;
+    }
+
+    @Override
+    public void setCertifiedText(boolean certifiedText) {
+    }
 }
< prev index next >