Package de.lessvoid.xml.lwxs.processor

Source Code of de.lessvoid.xml.lwxs.processor.IncludeProcessor

package de.lessvoid.xml.lwxs.processor;

import java.io.InputStream;
import java.util.Hashtable;
import java.util.Map;

import org.xmlpull.mxp1.MXParser;

import de.lessvoid.nifty.tools.resourceloader.ResourceLoader;
import de.lessvoid.xml.lwxs.Schema;
import de.lessvoid.xml.lwxs.elements.Type;
import de.lessvoid.xml.xpp3.Attributes;
import de.lessvoid.xml.xpp3.XmlParser;
import de.lessvoid.xml.xpp3.XmlProcessor;

public class IncludeProcessor implements XmlProcessor {
  private Map < String, Type > types = new Hashtable < String, Type >();

  public IncludeProcessor(final Map < String, Type > typesParam) {
    types = typesParam;
  }

  public void process(
      final XmlParser xmlParser,
      final Attributes attributes) throws Exception {
    String filename = attributes.get("filename");

    Schema niftyXmlSchema = new Schema();
    XmlParser parser = new XmlParser(new MXParser());
    InputStream stream = ResourceLoader.getResourceAsStream(filename);
    try {
      parser.read(stream);
      parser.nextTag();
      parser.required("nxs", niftyXmlSchema);

      types.putAll(niftyXmlSchema.getTypes());
      xmlParser.nextTag();
    } finally {
      stream.close();
    }
  }
}
TOP

Related Classes of de.lessvoid.xml.lwxs.processor.IncludeProcessor

TOP
Copyright © 2018 www.massapi.com. 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.