Package com.thaiopensource.xml.sax

Examples of com.thaiopensource.xml.sax.ErrorHandlerImpl


     */
    public static String validate(File schema, File xml) throws Exception {
        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
      ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
View Full Code Here


  public static void main(String[] args) throws Exception {
    generateXSDFromDTD(new File("rc-config.dtd"), new File("rc-config.xsd"));
  }
 
  public static void generateXSDFromDTD(File input, File output) throws Exception {
    ErrorHandlerImpl eh = new ErrorHandlerImpl();
    OutputFormat of = new XsdOutputFormat();
    InputFormat inFormat = new DtdInputFormat();
    SchemaCollection sc = inFormat.load(
        UriOrFile.toUri(input.getAbsolutePath()), new String[0], "xsd", eh);
   
View Full Code Here

   * @param input XML file (input)
   * @param output DTD file (output)
   * @throws Exception
   */
  public static void generateDTDFromXML(File input,File output) throws Exception {
    ErrorHandlerImpl eh = new ErrorHandlerImpl();
    OutputFormat of = new DtdOutputFormat();
    InputFormat inFormat = new XmlInputFormat();
    SchemaCollection sc = inFormat.load(
        UriOrFile.toUri(input.getAbsolutePath()), new String[0], "dtd", eh);
   
View Full Code Here

   * @param input XML file (input)
   * @param output XSD file (output)
   * @throws Exception
   */
  public static void generateXSDFromXML(File input,File output) throws Exception {
    ErrorHandlerImpl eh = new ErrorHandlerImpl();
    OutputFormat of = new XsdOutputFormat();
    InputFormat inFormat = new XmlInputFormat();
    SchemaCollection sc = inFormat.load(
        UriOrFile.toUri(input.getAbsolutePath()), new String[0], "xsd", eh);
   
View Full Code Here

     */
    public static String validate(File schema, File xml) throws Exception {
        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
  ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
View Full Code Here

            throws IOException {
        ByteArrayOutputStream error;
        try {
            PropertyMapBuilder properties = new PropertyMapBuilder();
            error = new ByteArrayOutputStream();
            ErrorHandlerImpl eh = new ErrorHandlerImpl(
                    new BufferedWriter(new OutputStreamWriter(error)));
            ValidateProperty.ERROR_HANDLER.put(properties, eh);
            SchemaReader schemaReader = new AutoSchemaReader();
            ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
            if (driver.loadSchema(schemaInputSource)) {
View Full Code Here

    public void run() throws SaxonApiException {
        super.run();

        boolean assertValid = getOption(_assert_valid,false);

        ErrorHandlerImpl eh = new ErrorHandlerImpl(System.out);
        PropertyMapBuilder properties = new PropertyMapBuilder();
        properties.put(ValidateProperty.ERROR_HANDLER, eh);
        RngProperty.CHECK_ID_IDREF.add(properties);

        properties.put(ValidateProperty.ENTITY_RESOLVER, runtime.getResolver());
View Full Code Here

     */
    public static String validate(File schema, File xml) throws Exception {
        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
      ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
View Full Code Here

    try {
      String rncFilePath = SchemaConverter.class.getClassLoader().getResource(schemaPath).toString().replace('\\', '/').replaceAll(" ","%20");
      InputFormat inputFormat = Formats.createInputFormat("rnc");
      OutputFormat outputFormat = Formats.createOutputFormat("rng");
      String[] inputOptions = {};
      SchemaCollection schemaCollection = inputFormat.load(rncFilePath, inputOptions, "rng", new ErrorHandlerImpl(), null);
      OutputDirectory outputDirectory = new LocalOutputDirectory(schemaCollection.getMainUri(), rngOutputFile, "rng", "UTF-8", 72, 2);
      String[] outputOptions = {};
     
      outputFormat.output(schemaCollection, outputDirectory, outputOptions, "rnc", new ErrorHandlerImpl());
    }
    catch(IOException | InputFailedException | InvalidParamsException | SAXException | OutputFailedException e) {
      throw new SchemaCreationException(e);
    }
   
View Full Code Here

     * otherwise.
     */
    public boolean doValidation(InputStream schema,
        String xmlFileName,
        OutputStream boust) {
  ErrorHandlerImpl eh = new ErrorHandlerImpl(System.out);
  PropertyMapBuilder properties = new PropertyMapBuilder();
  ValidateProperty.ERROR_HANDLER.put(properties, eh);
  RngProperty.CHECK_ID_IDREF.add(properties);
  SchemaReader sr = null;

  // Simulate -i option, since without the program barfs on
  // Oasis Open Document nrg.
  properties.put(RngProperty.CHECK_ID_IDREF, null);

  boolean hadError = false;
  try {
      ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), sr);
      InputSource in = new InputSource(schema);
      if (driver.loadSchema(in)) {

    if (!driver.validate(ValidationDriver.uriOrFileInputSource(xmlFileName)))
        hadError = true;
      }
      else
    hadError = true;
  }
  catch (SAXException e) {
      hadError = true;
      eh.printException(e);
  }
  catch (IOException e) {
      hadError = true;
      eh.printException(e);
  }
  return ! hadError;
    }
View Full Code Here

TOP

Related Classes of com.thaiopensource.xml.sax.ErrorHandlerImpl

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.