Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamException


        } catch (ClassCastException cce) {
            //not an XMLStreamReader2
            if (allowInsecureParser) {
                LOG.warning("INSTANCE_NOT_XMLSTREAMREADER2");
            } else {
                throw new XMLStreamException(cce.getMessage(), cce);
            }
        } catch (IllegalArgumentException cce) {
            //not a property supported by this version of woodstox
            if (allowInsecureParser) {
                LOG.log(Level.WARNING, "SECURE_PROPERTY_NOT_SUPPORTED", cce.getMessage());
            } else {
                throw new XMLStreamException(cce.getMessage(), cce);
            }
        }
        return reader;
    }
View Full Code Here


            multiSchemaReader.parse(domSource);
        }
       
        XMLSchemaGrammar grammar = multiSchemaReader.getResult();
        if (grammar == null) {
            throw new XMLStreamException("Failed to load schemas");
        }
        return new W3CSchema(grammar);
    }
View Full Code Here

        return new W3CSchema(grammar);
    }

    @Override
    protected XMLValidationSchema loadSchema(InputSource src, Object sysRef) throws XMLStreamException {
        throw new XMLStreamException("W3CMultiSchemaFactory does not support the provider API.");
    }
View Full Code Here

            }
            int read = 0;
            do {
                int c = stream.read(startBytes, read, 4-read);
                if (c == -1) {
                    throw new XMLStreamException("Unexpected end of stream");
                }
                read += c;
            } while (read < 4);
            if (useMark) {
                stream.reset();
            } else {
                ((PushbackInputStream)stream).unread(startBytes);
            }
        } catch (IOException ex) {
            throw new XMLStreamException("Unable to read start bytes", ex);
        }
        int marker = ((startBytes[0] & 0xFF) << 24) + ((startBytes[1] & 0xFF) << 16)
                + ((startBytes[2] & 0xFF) << 8) + (startBytes[3] & 0xFF);
        switch (marker) {
            case 0x0000FEFF:
View Full Code Here

    private void processAttribute(String namespaceURI, String localName, String value)
            throws XMLStreamException {
        if ((namespaceURI == null || namespaceURI.length() == 0)
                && localName.equals(XOPConstants.HREF)) {
            if (!value.startsWith("cid:")) {
                throw new XMLStreamException("Expected href attribute containing a URL in the " +
                        "cid scheme");
            }
            try {
                contentID = URLDecoder.decode(value.substring(4), "ascii");
            } catch (UnsupportedEncodingException ex) {
                // We should never get here
                throw new XMLStreamException(ex);
            }
        } else {
            throw new XMLStreamException("Expected xop:Include element information item with " +
                    "a (single) href attribute");
        }
    }
View Full Code Here

    }
   
    public void writeEndElement() throws XMLStreamException {
        if (inXOPInclude) {
            if (contentID == null) {
                throw new XMLStreamException("Encountered an xop:Include element without " +
                    "href attribute");
            }
            // TODO: we should create a DataHandlerProvider if isLoaded returns false for the given contentID
            DataHandler dh;
            try {
                dh = mimePartProvider.getDataHandler(contentID);
            } catch (IOException ex) {
                throw new XMLStreamException("Error while fetching data handler", ex);
            }
            try {
                dataHandlerWriter.writeDataHandler(dh, contentID, true);
            } catch (IOException ex) {
                throw new XMLStreamException("Error while writing data handler", ex);
            }
            inXOPInclude = false;
            contentID = null;
        } else {
            super.writeEndElement();
View Full Code Here

    protected void doWriteEndDocument() {
        // Do nothing
    }

    protected void doWriteDTD(String dtd) throws XMLStreamException {
        throw new XMLStreamException("A DTD must not appear in element content");
    }
View Full Code Here

            } else {
                dataHandlerWriter.writeDataHandler(dataHandlerReader.getDataHandler(),
                        dataHandlerReader.getContentID(), dataHandlerReader.isOptimized());
            }
        } catch (IOException ex) {
            throw new XMLStreamException("Error while reading data handler", ex);
        }
    }
View Full Code Here

            dtdReader = (DTDReader)reader.getProperty(DTDReader.PROPERTY);
        } catch (IllegalArgumentException ex) {
            dtdReader = null;
        }
        if (dtdReader == null) {
            throw new XMLStreamException("Cannot serialize the DTD because the XMLStreamReader doesn't support the DTDReader extension");
        }
        XMLStreamWriterUtils.writeDTD(writer, dtdReader.getRootName(), dtdReader.getPublicId(),
                dtdReader.getSystemId(), reader.getText());
    }
View Full Code Here

     * @throws XMLStreamException
     */
    private String processXopInclude() throws XMLStreamException {
        if (super.getAttributeCount() != 1 ||
                !super.getAttributeLocalName(0).equals(XOPConstants.HREF)) {
            throw new XMLStreamException("Expected xop:Include element information item with " +
                    "a (single) href attribute");
        }
        String href = super.getAttributeValue(0);
        if(log.isDebugEnabled()){
             log.debug("processXopInclude - found href : " + href);
        }
        if (!href.startsWith("cid:")) {
            throw new XMLStreamException("Expected href attribute containing a URL in the " +
                    "cid scheme");
        }
        String contentID;
        try {
            // URIs should always be decoded using UTF-8. On the other hand, since non ASCII
            // characters are not allowed in content IDs, we can simply decode using ASCII
            // (which is a subset of UTF-8)
            contentID = URLDecoder.decode(href.substring(4), "ascii");
            if(log.isDebugEnabled()){
                 log.debug("processXopInclude - decoded contentID : " + contentID);
            }
        } catch (UnsupportedEncodingException ex) {
            // We should never get here
            throw new XMLStreamException(ex);
        }
        if (super.next() != END_ELEMENT) {
            throw new XMLStreamException(
                    "Expected xop:Include element information item to be empty");
        }
        // Also consume the END_ELEMENT event of the xop:Include element. There are
        // two reasons for this:
        //  - It allows us to validate that the message conforms to the XOP specs.
        //  - It makes it easier to implement the getNamespaceContext method.
        if (super.next() != END_ELEMENT) {
            throw new XMLStreamException(SOLE_CHILD_MSG);
        }
        if (log.isDebugEnabled()) {
            log.debug("Encountered xop:Include for content ID '" + contentID + "'");
        }
        return contentID;
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamException

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.