Example usage for javax.xml XMLConstants RELAXNG_NS_URI

List of usage examples for javax.xml XMLConstants RELAXNG_NS_URI

Introduction

In this page you can find the example usage for javax.xml XMLConstants RELAXNG_NS_URI.

Prototype

String RELAXNG_NS_URI

To view the source code for javax.xml XMLConstants RELAXNG_NS_URI.

Click Source Link

Document

RELAX NG Namespace URI.

Usage

From source file:com.consol.citrus.samples.bookstore.validation.XmlSchemaValidatingChannelInterceptor.java

/**
 * Constructor./*  ww  w  .  ja v a2 s  . co m*/
 * 
 * @param schemaResource
 * @param schemaLanguage
 * @throws IOException
 */
public XmlSchemaValidatingChannelInterceptor(Resource schemaResource, String schemaLanguage)
        throws IOException {
    if (schemaLanguage.equals("xml-schema")) {
        this.xmlValidator = XmlValidatorFactory.createValidator(schemaResource,
                XMLConstants.W3C_XML_SCHEMA_NS_URI);
    } else {
        this.xmlValidator = XmlValidatorFactory.createValidator(schemaResource, XMLConstants.RELAXNG_NS_URI);
    }
}

From source file:org.jopendocument.dom.OOXML.java

/**
 * Verify that the passed document is a valid OpenOffice.org 1 or ODF document.
 * //w  w  w.  j  a  v  a2 s. c o m
 * @param doc the xml to test.
 * @return <code>null</code> if <code>doc</code> is valid, a String describing the pb otherwise.
 */
public final String isValid(Document doc) {
    if (this.getVersion().equals(XMLVersion.OD))
        try {
            return JDOMUtils.isValid(doc, XMLConstants.RELAXNG_NS_URI,
                    getClass().getResource("oofficeDTDs/OpenDocument-strict-schema-v1.1.rng"));
        } catch (SAXException e) {
            throw new IllegalStateException("relaxNG schemas pb", e);
        }
    else {
        // DTDs are stubborn, xmlns have to be exactly where they want
        // in this case the root element
        for (final Namespace n : getVersion().getALL())
            doc.getRootElement().addNamespaceDeclaration(n);
        return JDOMUtils.isValidDTD(doc, OOUtils.getBuilderLoadDTD());
    }
}