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


     */
    public static DocumentHandler getDefaultSerializer( OutputStream output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

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

     */
    public static DocumentHandler getDefaultSerializer( Writer output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

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

     */
    public DocumentHandler getSerializer( OutputStream output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

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

     */
    public DocumentHandler getSerializer( Writer output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputCharStream( output );
        docHandler = serializer.asDocumentHandler();
        if ( docHandler == null )
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

            Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
            document = (Document) unmarshaller.unmarshal(new EventProducer()
                {
                    public void setDocumentHandler(final DocumentHandler handler)
                    {
                        readerAdapter.setDocumentHandler(new DocumentHandler()
                            {
                                private int menuDepth = 0;

                                public void characters(char[] ch, int start, int length) throws SAXException
                                {
View Full Code Here

  }

  /** writes TypeItem to an XML file. */
  private void write( TypeItem type ) throws SAXException, IOException {
       
    DocumentHandler outHandler = new XMLSerializer(
      controller.getOutput(type),
      new OutputFormat("xml",null,true) );
    XMLWriter out = new XMLWriter(outHandler);
       
    outHandler.setDocumentLocator( new LocatorImpl() );
    outHandler.startDocument();
    outHandler.processingInstruction("xml-stylesheet",
      "type='text/xsl' href='classFileDebug.xsl'");
    writeClass( type, out );
    outHandler.endDocument();
  }
View Full Code Here

   
  // generate a grammar file
  //-----------------------------------------
    System.err.println("generating a grammar file...");
   
    DocumentHandler grammarReceiver = null;
    if( out==xml ) {
      grammarReceiver = new XMLSerializer(
        new FileOutputStream( new File( outDir, "grammar.xml" ) ),
        new OutputFormat("xml",null,true) );
    } else {
      TransformerHandler xsltEngine = XSLTUtil.getTransformer(
        Driver.class.getResourceAsStream("grammar2java.xsl"));
      xsltEngine.setResult( new StreamResult(
        new FileOutputStream( getJavaFile(outDir,grammar.grammarName)) ));
     
      grammarReceiver = new com.sun.msv.writer.ContentHandlerAdaptor(xsltEngine);
    }

    Rules rules = RuleGenerator.create(grammar);
   
    Symbolizer symbolizer =
      RuleSerializer.serialize( grammar, rules, grammarReceiver );

 
  // generate marshallers
  //-----------------------------------------
    if( out==xml ) {
      System.err.println("generating marshallers...");
      DocumentHandler marshallerReceiver = null;
      marshallerReceiver = new XMLSerializer(
        new FileOutputStream( new File( outDir, "marshaller.xml" ) ),
        new OutputFormat("xml",null,true) );
      MarshallerSerializer.serialize( grammar, symbolizer, grammarController, marshallerReceiver );
    }
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

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.