Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXSource


        } else {
            inputSource = new InputSource(source.getInputStream());
        }
        inputSource.setSystemId(source.getSystemId());
        inputSource.setPublicId(source.getPublicId());
        return new SAXSource(inputSource);
    }
View Full Code Here


    public SAXSource toSAXSourceFromDOM(DOMSource source) throws TransformerException {
        if (dom2SaxClass != null) {
            try {
                Constructor cns = dom2SaxClass.getConstructor(new Class[] { Node.class });
                XMLReader converter = (XMLReader) cns.newInstance(new Object[] { source.getNode() });
                return new SAXSource(converter, new InputSource());
            } catch (Exception e) {
                throw new TransformerException(e);
            }
        } else {
            String str = toString(source);
            StringReader reader = new StringReader(str);
            return new SAXSource(new InputSource(reader));
        }
    }
View Full Code Here


        NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        currentPublicId.set(new TreeSet<String>());
        try {
            return (T) unmarshaller.unmarshal(source);
        } finally {
View Full Code Here

        PropertyMap propertyMap = mapBuilder.toPropertyMap();

        Validator validator = getSchema().createValidator(propertyMap);

        Message in = exchange.getIn();
        SAXSource saxSource = in.getBody(SAXSource.class);
        if (saxSource == null) {
            Source source = ExchangeHelper.getMandatoryInBody(exchange, Source.class);
            saxSource = ExchangeHelper.convertToMandatoryType(exchange, SAXSource.class, source);
        }
        InputSource bodyInput = saxSource.getInputSource();

        // now lets parse the body using the validator
        XMLReader reader = xmlCreator.createXMLReader();
        reader.setContentHandler(validator.getContentHandler());
        reader.setDTDHandler(validator.getDTDHandler());
View Full Code Here


        NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);
//        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<PluginArtifactType> element = unmarshaller.unmarshal(source, PluginArtifactType.class);
        PluginArtifactType plugin = element.getValue();
        return plugin;
    }
View Full Code Here

   
    public static final QName XSD = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema");

    private Collection<? extends Source> aggregate(URL... urls) throws IOException, XMLStreamException {
        if (urls.length == 1) {
            return Collections.singletonList(new SAXSource(XMLDocumentHelper.getInputSource(urls[0])));
        }
        Map<String, Collection<URL>> map = new HashMap<String, Collection<URL>>();

        for (URL url : urls) {
            String tns = helper.readAttribute(url, XSD, "targetNamespace");
            Collection<URL> collection = map.get(tns);
            if (collection == null) {
                collection = new HashSet<URL>();
                map.put(tns, collection);
            }
            collection.add(url);
        }
        List<Source> sources = new ArrayList<Source>();
        for (Map.Entry<String, Collection<URL>> e : map.entrySet()) {
            if (e.getValue().size() == 1) {
                sources.add(new SAXSource(XMLDocumentHelper.getInputSource(e.getValue().iterator().next())));
            } else {
                StringBuffer xsd = new StringBuffer("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"");
                if (e.getKey() != null) {
                    xsd.append(" targetNamespace=\"").append(e.getKey()).append("\"");
                }
                xsd.append(">");
                for (URL url : e.getValue()) {
                    xsd.append("<include schemaLocation=\"").append(url).append("\"/>");
                }
                xsd.append("</schema>");
                SAXSource source = new SAXSource(new InputSource(new StringReader(xsd.toString())));
                sources.add(source);
            }
        }
        return sources;
    }
View Full Code Here

                System.out.println(validationEvent);
                return false;
            }
        });

        SAXSource source;
        if (filter) {
            NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
            xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
            source = new SAXSource(xmlFilter, inputSource);
        } else {
            source = new SAXSource(inputSource);
        }

        currentPublicId.set(new TreeSet<String>());
        try {
            return unmarshaller.unmarshal(source, type).getValue();
View Full Code Here

        JavaeeNamespaceFilter xmlFilter = new JavaeeNamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
       
        // unmarshall
        SAXSource source = new SAXSource(xmlFilter, new InputSource(in));
       
        currentPublicId.set(new TreeSet<String>());
        try {
            JAXBElement<T> element = unmarshaller.unmarshal(source, type);
            return element.getValue();
View Full Code Here

        });

        JaxbJavaee.NoSourceFilter xmlFilter = new JaxbJavaee.NoSourceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        currentPublicId.set(new TreeSet<String>());
        try {
            return unmarshaller.unmarshal(source);
        } finally {
View Full Code Here


        JaxbJavaee.TaglibNamespaceFilter xmlFilter = new JaxbJavaee.TaglibNamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        currentPublicId.set(new TreeSet<String>());
        try {
            return unmarshaller.unmarshal(source);
        } finally {
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.SAXSource

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.