com.sun.msv.util.xml.SAXEventGenerator Maven / Gradle / Ivy
/*
* @(#)$Id: SAXEventGenerator.java,v 1.4 2003/06/09 20:37:41 kk122374 Exp $
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
package com.sun.msv.util.xml;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.LocatorImpl;
/**
* produces SAX2 event from a DOM tree.
*
* @author
* Kohsuke KAWAGUCHI
*/
public class SAXEventGenerator {
/**
* scans the specified DOM and sends SAX2 events to the handler.
*/
public static void parse( Document dom, final ContentHandler handler ) throws SAXException {
DOMVisitor visitor = new DOMVisitor(){
public void visit( Element e ) {
int attLen = e.getAttributes().getLength();
AttributesImpl atts = new AttributesImpl();
for( int i=0; i © 2015 - 2025 Weber Informatics LLC | Privacy Policy