Package org.apache.ws.jaxme.xs.parser

Examples of org.apache.ws.jaxme.xs.parser.XSContext


  protected void setSchema(XSSchema pSchema) {
    schema = pSchema;
  }
 
  protected XsESchema parseSyntax(Node pNode) throws SAXException {
    XSContext data = getData();
    try {
      XsObjectFactory factory = data.getXsObjectFactory();
      XsESchema mySchema = factory.newXsESchema();
      XsSAXParser xsSAXParser = factory.newXsSAXParser(mySchema);
      addSyntaxSchema(mySchema);
      try {
        data.setCurrentContentHandler(xsSAXParser);
        DOMSerializer ds = new DOMSerializer();
        ds.serialize(pNode, xsSAXParser);
        return (XsESchema) xsSAXParser.getBean();
      } finally {
        removeSyntaxSchema();
      }
    } finally {
      data.setCurrentContentHandler(null);
    }
  }
View Full Code Here


  }
 
  protected void parseSyntax(Locator pLocator, String pSchemaLocation,
      XsESchema pSchema)
  throws SAXException, IOException, ParserConfigurationException {
    XSContext data = getData();
    try {
      XsObjectFactory factory = data.getXsObjectFactory();
      XMLReader xr = factory.newXMLReader(isValidating());
      EntityResolver entityResolver = xr.getEntityResolver();
      InputSource schemaSource = null;
      if (entityResolver != null) {
        schemaSource = entityResolver.resolveEntity(null, pSchemaLocation);
      }
      if (schemaSource == null) {
        schemaSource = getInputSource(pLocator == null ? null : pLocator.getSystemId(),
            pSchemaLocation);
      }
     
      XsSAXParser xsSAXParser = factory.newXsSAXParser(pSchema);
      addSyntaxSchema(pSchema);
      try {
        data.setCurrentContentHandler(xsSAXParser);
        xr.setContentHandler(xsSAXParser);
        xr.parse(schemaSource);
      } finally {
        removeSyntaxSchema();
      }
    } finally {
      data.setCurrentContentHandler(null);
    }
  }
View Full Code Here

  /** <p>Redefines the given {@link XsRedefinable}.</p>
   */
  protected void redefine(XsESchema pSyntaxSchema,
      XsERedefine pRedefine, XsRedefinable pChild) throws SAXException {
    XSSchema mySchema = getSchema();
    XSContext data = getData();
    XSObjectFactory factory = data.getXSObjectFactory();
    if (pChild instanceof XsTAttributeGroup) {
      XsTAttributeGroup attributeGroup = (XsTAttributeGroup) pChild;
      mySchema.redefine(factory.newXSAttributeGroup(mySchema, attributeGroup));
    } else if (pChild instanceof XsTNamedGroup) {
      XsTNamedGroup group = (XsTNamedGroup) pChild;
View Full Code Here

  /** <p>Adds the given object to the schema.</p>
   *
   */
  protected void add(XsESchema pSyntaxSchema, Object pChild) throws SAXException {
    XSSchema mySchema = getSchema();
    XSContext data = getData();
    XSObjectFactory factory = data.getXSObjectFactory();
    if (pChild instanceof XsEAnnotation) {
      XsEAnnotation annotation = (XsEAnnotation) pChild;
      mySchema.add(factory.newXSAnnotation(mySchema, annotation));
    } else if (pChild instanceof XsETopLevelSimpleType) {
      XsETopLevelSimpleType type = (XsETopLevelSimpleType) pChild;
View Full Code Here

   * @see #getXSContentHandler()
   */
  public XSSchema parse(InputSource pSource)
  throws ParserConfigurationException, SAXException, IOException {
    XSContentHandler contentHandler = getXSContentHandler(pSource.getSystemId());
    XSContext data = getData();
    XMLReader xr = data.getXsObjectFactory().newXMLReader(isValidating());
    xr.setContentHandler(contentHandler);
    xr.parse(pSource);
    return getSchema();
  }
View Full Code Here

    /** Sets the document locator.
     */
    public void setLocator(Locator pLocator) {
      locator = pLocator;
        XSContext context = getData();
        if (context != null) {
          context.setLocator(pLocator);
        }
    }
View Full Code Here

  /** <p>Parses the given XML schema. and returns a syntactical
   * representation.</p>
   * @see #parse(InputSource)
   */
  public XsESchema parseSyntax(InputSource pSource) throws ParserConfigurationException, SAXException, IOException {
    XSContext context = getContext();
    parser.set(this);
    try {
      XsObjectFactory factory = context.getXsObjectFactory();
      XsSAXParser xsSAXParser = factory.newXsSAXParser();
      context.setCurrentContentHandler(xsSAXParser);
      XMLReader xr = factory.newXMLReader(isValidating());
      xr.setContentHandler(xsSAXParser);
      xr.parse(pSource);
      return (XsESchema) xsSAXParser.getBean();
    } finally {
      context.setCurrentContentHandler(null);
      parser.set(null);
    }
  }
View Full Code Here

  }

  /** <p>Parses the given XML schema and returns a logical representation.</p>
   */
  public XSSchema parse(InputSource pSource) throws ParserConfigurationException, SAXException, IOException {
    XSContext myData = getContext();
    parser.set(this);
    try {
      return newXSLogicalParser().parse(pSource);
    } finally {
      myData.setCurrentContentHandler(null);
      parser.set(null);
    }
  }
View Full Code Here

   *   {@link org.w3c.dom.Element}, or an instance of
   *   {@link org.w3c.dom.DocumentFragment}. In the latter case, make
   *   sure, that the fragment contains a single root element.
   */
  public XSSchema parse(Node pNode) throws SAXException {
    XSContext myData = getContext();
    parser.set(this);
    try {
      return newXSLogicalParser().parse(pNode);
    } finally {
      myData.setCurrentContentHandler(null);
      parser.set(null);
    }
  }
View Full Code Here

  private boolean finished;
  private int level = 0;

  XSContentHandlerImpl(XSLogicalParser pParser) throws SAXException {
    parser = pParser;
    XSContext data = parser.getData();
    data.setXSLogicalParser(parser);
    parser.clearSyntaxSchemas();
    XsObjectFactory factory = data.getXsObjectFactory();
    XsESchema mySchema = factory.newXsESchema();
    parser.setSchema(data.getXSObjectFactory().newXSSchema(data, mySchema));
    xsSAXParser = factory.newXsSAXParser(mySchema);
    parser.addSyntaxSchema(mySchema);
    data.setCurrentContentHandler(xsSAXParser);
  }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.parser.XSContext

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.