Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlException


        final XmlOptions options = new XmlOptions();
        options.setErrorListener(list);
        final JzeemapConfigurationDocument doc = JzeemapConfigurationDocument.Factory.parse(file);
        boolean validate = doc.validate(options);
        if (!validate) {
          throw new XmlException("", null, list);
        } else {
          final App app = new App(doc.getJzeemapConfiguration());
          app.start();
        }
      } catch (XmlException ex) {
View Full Code Here


       PackagePart corePart = getCorePart();
      return corePart.getRelatedPart(
        corePart.getRelationship(master.getId2())
      );
    } catch(InvalidFormatException e) {
      throw new XmlException(e);
    }
  }
View Full Code Here

        PackagePart corePart = getCorePart();
        return corePart.getRelatedPart(
           corePart.getRelationship(slide.getId2())
        );
    } catch(InvalidFormatException e) {
      throw new XmlException(e);
    }
  }
View Full Code Here

            getName(), context.getPath(), "Non-nillable element is nil." ) )
        {
          setAttribute( "nillable", "true" );
        }
        else
          throw new XmlException( "Non-nillable element is nil!" );
      }
      context.putAttribute( "nil", "true" );
    }
    Type newType = type.validate( context );
    if( newType != type )
    {
      String problem = "Illegal content for element '" + name + "' with type '" + type.getName() + "'.";
      if( type instanceof TypeReferenceType
          || context.getHandler().callback( ConflictHandler.Event.MODIFICATION, ConflictHandler.Type.ELEMENT,
              getName(), context.getPath(), "Illegal content." ) )
      {
        type = newType;
        context.getCursor().pop();
        context.up();
        validate( context );
        return;
      }
      else
        throw new XmlException( problem );
    }
    context.clearAttribute( "nil" );
    context.up();
    context.getCursor().pop();
  }
View Full Code Here

        context.getCursor().pop();
        validate( context );
        return;
      }
      else
        throw new XmlException( problem );
    }
    context.getCursor().pop();
  }
View Full Code Here

    SchemaTypeSystem sts = XmlBeans.compileXsd( new XmlObject[] { XmlObject.Factory
        .parse( "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"><element name=\"" + name + "\">" + xsd
            + "</element></schema>" ) }, XmlBeans.getBuiltinTypeSystem(), null );
    SchemaTypeLoader stl = XmlBeans.typeLoaderUnion( new SchemaTypeLoader[] { sts, XmlBeans.getBuiltinTypeSystem() } );
    if( !stl.parse( context.getCursor().xmlText(), null, null ).validate() )
      throw new XmlException( "Element '" + name + "' does not validate for custom type!" );
    return this;
  }
View Full Code Here

          "/" + cursor.getName().getLocalPart(), "Undeclared root element." ) )
      {
        root = newElement( cursor.getName().getLocalPart() );
      }
      else
        throw new XmlException( "Illegal root element" );
    }

    root.validate( context );
  }
View Full Code Here

  public Content validate( Context context ) throws XmlException
  {
    XmlCursor cursor = context.getCursor();
    String value = "";
    if( cursor.isStart() )
      throw new XmlException( "Unsupported!" );
    if( !cursor.isEnd() )
      value = cursor.getTextValue();
    if( !TypeInferrer.validateSimpleType( value, simpleType ) )
    {
      XmlAnySimpleType newSimpleType = TypeInferrer.expandTypeForValue( value, simpleType );
      if( context.getHandler().callback( ConflictHandler.Event.MODIFICATION, ConflictHandler.Type.TYPE,
          new QName( schema.getNamespace(), context.getAttribute( "typeName" ) ), context.getPath(),
          "Illegal value." ) )
      {
        simpleType = newSimpleType;
      }
      else
        throw new XmlException( "Illegal content!" );
    }
    return this;
  }
View Full Code Here

        {
          if( !orderSet.get( orderSet.size() - 1 ).equals( qname ) )
          {
            // Same element occurs more an once but not in a sequence!
            cursor.pop();
            throw new XmlException( "Same element occurs multiple times in sequence!" );
          }
        }
        else
          orderSet.add( qname );
        orderList.add( qname );
      }
      while( cursor.toNextSibling() );
      cursor.pop();
    }
    // Check element order against schema
    if( validateOrder( context, orderSet ) && validateOccurances( context, orderList ) )
    {
      // Validate elements
      for( QName item : orderList )
      {
        cursor.push();
        particles.get( item ).validate( context );
        cursor.pop();
        cursor.toNextSibling();
      }
    }
    else
      throw new XmlException( "Sequence validation" );
    completed = true;
    return this;
  }
View Full Code Here

            entry.getKey(), context.getPath(), "Element occurs less times than required." ) )
        {
          particle.setAttribute( "minOccurs", entry.getValue().toString() );
        }
        else
          throw new XmlException( "Element '" + entry.getKey().getLocalPart()
              + "' required at least minOccurs times!" );
      }
      if( !particle.getAttribute( "maxOccurs" ).equals( "unbounded" )
          && Integer.parseInt( particle.getAttribute( "maxOccurs" ) ) < entry.getValue() )
      {
        if( context.getHandler().callback( ConflictHandler.Event.MODIFICATION, ConflictHandler.Type.TYPE,
            new QName( schema.getNamespace(), context.getAttribute( "typeName" ) ), context.getPath(),
            "Element occurs more times than allowed." ) )
        {
          particle.setAttribute( "maxOccurs", entry.getValue().toString() );
        }
        else
          throw new XmlException( "Element '" + entry.getKey().getLocalPart()
              + "' must not occur more than maxOccurs times!" );
      }
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlException

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.