Package javax.xml.validation

Examples of javax.xml.validation.SchemaFactory


    }   
  }

  static Unmarshaller getUnMarsheller() throws JAXBException, SAXException {
    JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
    Unmarshaller un = jc.createUnmarshaller();
    un.setSchema(schema);
    return un;
  }
View Full Code Here


   
    roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
   
    vdb.addDataPolicy(roleOne);
   
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd"));      //$NON-NLS-1$
    JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
    Marshaller marshell = jc.createMarshaller();
    marshell.setSchema(schema);
    marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
   
View Full Code Here

        wrapperAnnotation = method.getAnnotation(RequestWrapper.class);
       
        InputStream is =  getClass().getResourceAsStream("resources/StringStruct.xsd");
        StreamSource schemaSource = new StreamSource(is);
        assertNotNull(schemaSource);
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        schema = factory.newSchema(schemaSource);
        assertNotNull(schema);
    }
View Full Code Here

        deserialize(document);

        Source src = new DOMSource(document);
        src.setSystemId(is.getSystemId());

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        final LSResourceResolver oldResolver = factory.getResourceResolver();
    
        LSResourceResolver resolver = new LSResourceResolver() {

            public LSInput resolveResource(String type, String nsURI,
                                           String publicId, String systemId, String baseURI) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("resolving resource type: " + type + "\n"
                            + "                   namespaceURI:" + nsURI + "\n"
                            + "                   publicId:" + publicId + "\n"
                            + "                   systemId:" + systemId + "\n"
                            + "                   baseURI:" + baseURI);
                }
               
                if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type)) {
                    LSInput lsi = new SchemaInput(type, nsURI, publicId, systemId, baseURI);
                    String resourceName = systemId;
                   
                    InputSource src = getSchemaInputSource(baseURI, resourceName);
                    lsi.setByteStream(src.getByteStream());
                    lsi.setSystemId(src.getSystemId());
                    return lsi;
                }
                return oldResolver == null ? null
                    : oldResolver.resolveResource(type, nsURI, publicId, systemId, baseURI);
            }
        };
       
        factory.setResourceResolver(resolver);       
        try {
            schema = factory.newSchema(src);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG, location), ex);
        }
        document = null;
       
View Full Code Here

    }

    private Schema getSchema(InputStream is) {
        Source schemaFile = new StreamSource(is);

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = null;
        try {
            schema = factory.newSchema(schemaFile);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG), ex);
        }
        return schema;
    }
View Full Code Here

            }
        }
        Schema schema = schemaMap.get(definition);
        if (schema == null) {
            List<javax.wsdl.extensions.schema.Schema> schemas = getSchemas(definition);
            SchemaFactory factory = SchemaFactory.newInstance(
                XMLConstants.W3C_XML_SCHEMA_NS_URI);
            List<Source> schemaSources = new ArrayList<Source>();
            for (javax.wsdl.extensions.schema.Schema s : schemas) {
                Source source = new DOMSource(s.getElement());
                if (source != null) {
                    schemaSources.add(source);
                }
            }
            try {
                schema = factory.newSchema(schemaSources.toArray(
                    new Source[schemaSources.size()]));
                if (schema != null) {
                    synchronized (schemaMap) {
                        schemaMap.put(definition, schema);
                    }
View Full Code Here

         {
            mapper = new XmlNamespacePrefixMapper(config.namespaces());
         }
         if (!"".equals(config.schema()))
         {
            SchemaFactory schemaFactory = SchemaFactory.newInstance(config.schemaType());
            try
            {
               InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(
                       config.schema());
               schema = schemaFactory.newSchema(new StreamSource(in));
            }
            catch (SAXException e)
            {
               throw new JAXBException("Error wil trying to load schema for " + config.schema(), e);
            }
View Full Code Here

    return result;
  }

  private Schema loadSchema() {
    SchemaFactory sf = SchemaFactory
        .newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$
    Schema s = null;
    try {
      s = sf.newSchema(getClass().getResource("/WEB-INF/schemas/po.xsd")); //$NON-NLS-1$
    } catch (SAXException e) {
      e.printStackTrace();
    }
    return s;
  }
View Full Code Here

   
    private SyslogMessage test(String message) throws Exception {
        MessageContext msgContext = new MessageContext();
        ByteArrayInputStream in = new ByteArrayInputStream(message.getBytes("us-ascii"));
        OMElement element = new SyslogMessageBuilder().processDocument(in, null, msgContext);
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = factory.newSchema(new StreamSource(SyslogMessageBuilderTest.class.getResource("schema.xsd").toExternalForm()));
        Validator validator = schema.newValidator();
        validator.setErrorHandler(new ErrorHandler() {
            public void error(SAXParseException exception) throws SAXException {
                throw exception;
            }
View Full Code Here

        return clone;
    }

   
    public void validateSchema(Element ele) throws ToolException {
        SchemaFactory schemaFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        DOMSource domSrc = new DOMSource(ele);
        try {
            schemaFact.newSchema(domSrc);
        } catch (SAXException e) {
            if (e.getLocalizedMessage().indexOf("src-resolve.4.2") > -1)  {
                //Ignore schema resolve error and do nothing
            } else {
                throw new ToolException("Schema Error : " + e.getLocalizedMessage(), e);
View Full Code Here

TOP

Related Classes of javax.xml.validation.SchemaFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.