Package org.xml.sax

Examples of org.xml.sax.DocumentHandler


      if ( ! _insideRoot )
    throw new SAXException( Messages.format( "dsml.expectingOpeningTag",
               XML.Namespace.Root, tagName ) );
      if ( tagName.equals( XML.Schema.Element ) ||
     tagName.equals( XML.Entries.Element ) ) {
    DocumentHandler entry;

    entry = getEntryConsumer();
    entry.startElement( tagName, attr );
    _redirect = entry;
      } else {
    throw new SAXException( Messages.format( "dsml.openingTagNotRecognized",
               tagName ) );
      }
View Full Code Here


        Parser parser = Configuration.getDefaultParser();
        if (parser == null) {
            throw new SAXException("Unable to create parser");
        }

        DocumentHandler handler = new AttributeInterceptor();
        parser.setDocumentHandler(handler);
        try {
            parser.parse(new InputSource(_reader));
        } catch (IOException exception) {
            throw new SAXException(exception.getMessage(), exception);
View Full Code Here

            throw new IOException("Unable to obtain serailizer");
        }

        serializer.setOutputCharStream(writer);

        DocumentHandler handler = serializer.asDocumentHandler();

        if (handler == null) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
View Full Code Here

            throw new IOException(message);
        }

        serializer.setOutputCharStream(writer);

        DocumentHandler handler = serializer.asDocumentHandler();

        if (handler == null) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
View Full Code Here

    /**
     * @see org.castor.xml.InternalContext#getSerializer(java.io.OutputStream)
     */
    public DocumentHandler getSerializer(final OutputStream output) throws IOException {
        Serializer serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputByteStream(output);
        docHandler = serializer.asDocumentHandler();
        if (docHandler == null) {
View Full Code Here

    /**
     * @see org.castor.xml.InternalContext#getSerializer(java.io.Writer)
     */
    public DocumentHandler getSerializer(final Writer output) throws IOException {
        Serializer serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputCharStream(output);
        docHandler = serializer.asDocumentHandler();
        if (docHandler == null) {
View Full Code Here

       
        nameClassWriter = createNameClassWriter();       
        // generates SAX events
        try {
            final DocumentHandler handler = writer.getDocumentHandler();
            handler.setDocumentLocator( new LocatorImpl() );
            handler.startDocument();

            // to work around the bug of current serializer,
            // report xmlns declarations as attributes.
           
            if( defaultNs!=null )
                writer.start("grammar",new String[]{
                    "ns",defaultNs,
                    "xmlns",RELAXNGReader.RELAXNGNamespace,
                    "datatypeLibrary", XSDVocabulary.XMLSchemaNamespace });
            else
                writer.start("grammar", new String[]{
                    "xmlns",RELAXNGReader.RELAXNGNamespace,
                    "datatypeLibrary", XSDVocabulary.XMLSchemaNamespace });
           
           
            {// write start pattern.
                writer.start("start");
                writeIsland( g.getTopLevel() );
                writer.end("start");
            }
           
            // write all named expressions
            Iterator itr = exp2name.keySet().iterator();
            while( itr.hasNext() ) {
                Expression exp = (Expression)itr.next();
                String name = (String)exp2name.get(exp);
                if( exp instanceof ReferenceExp )
                    exp = ((ReferenceExp)exp).exp;
                writer.start("define",new String[]{"name",name});
                writeIsland( exp );
                writer.end("define");
            }
           
            writer.end("grammar");
            handler.endDocument();
        } catch( SAXRuntimeException sw ) {
            throw sw.e;
        }
    }
View Full Code Here

        if (serializer == null)
            throw new IOException("Unable to obtain serailizer");

        serializer.setOutputCharStream( writer );

        DocumentHandler handler = serializer.asDocumentHandler();

        if ( handler == null ) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
View Full Code Here

      if ( ! _insideRoot )
    throw new SAXException( Messages.format( "dsml.expectingOpeningTag",
               XML.Namespace.Root, tagName ) );
      if ( tagName.equals( XML.Schema.Element ) ||
     tagName.equals( XML.Entries.Element ) ) {
    DocumentHandler entry;

    entry = getEntryConsumer();
    entry.startElement( tagName, attr );
    _redirect = entry;
      } else {
    throw new SAXException( Messages.format( "dsml.openingTagNotRecognized",
               tagName ) );
      }
View Full Code Here

            // page and folder menu definition menu elements ordered
            // polymorphic collection to strip artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final DocumentHandler handler = serializer.asDocumentHandler();
            Marshaller marshaller = new Marshaller(new DocumentHandler()
                {
                    private int menuDepth = 0;

                    public void characters(char[] ch, int start, int length) throws SAXException
                    {
                        handler.characters(ch, start, length);
                    }

                    public void endDocument() throws SAXException
                    {
                        handler.endDocument();
                    }
                   
                    public void endElement(String name) throws SAXException
                    {
                        // track menu depth
                        if (name.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !name.equals("menu-element"))
                        {
                            handler.endElement(name);
                        }
                    }
                   
                    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                    {
                        handler.ignorableWhitespace(ch, start, length);
                    }
                   
                    public void processingInstruction(String target, String data) throws SAXException
                    {
                        handler.processingInstruction(target, data);
                    }
                   
                    public void setDocumentLocator(Locator locator)
                    {
                        handler.setDocumentLocator(locator);
                    }
                   
                    public void startDocument() throws SAXException
                    {
                        handler.startDocument();
                    }
                   
                    public void startElement(String name, AttributeList atts) throws SAXException
                    {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !name.equals("menu-element"))
                        {
                            handler.startElement(name, atts);
                        }

                        // track menu depth
                        if (name.equals("menu"))
                        {
View Full Code Here

TOP

Related Classes of org.xml.sax.DocumentHandler

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.