[jboss-svn-commits] JBoss Common SVN: r4498 - in jbossxb/branches/split: staxparser and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 11 11:24:37 EDT 2010
Author: alex.loubyansky at jboss.com
Date: 2010-06-11 11:24:37 -0400 (Fri, 11 Jun 2010)
New Revision: 4498
Added:
jbossxb/branches/split/staxparser/
jbossxb/branches/split/staxparser/trunk/
jbossxb/branches/split/staxparser/trunk/.classpath
jbossxb/branches/split/staxparser/trunk/.project
jbossxb/branches/split/staxparser/trunk/pom.xml
jbossxb/branches/split/staxparser/trunk/src/
jbossxb/branches/split/staxparser/trunk/src/main/
jbossxb/branches/split/staxparser/trunk/src/main/java/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/stax/
jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/stax/StaxJBossXBParser.java
jbossxb/branches/split/staxparser/trunk/src/main/resources/
jbossxb/branches/split/staxparser/trunk/src/test/
jbossxb/branches/split/staxparser/trunk/src/test/java/
jbossxb/branches/split/staxparser/trunk/src/test/resources/
Log:
stax parser for xb
Added: jbossxb/branches/split/staxparser/trunk/.classpath
===================================================================
--- jbossxb/branches/split/staxparser/trunk/.classpath (rev 0)
+++ jbossxb/branches/split/staxparser/trunk/.classpath 2010-06-11 15:24:37 UTC (rev 4498)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: jbossxb/branches/split/staxparser/trunk/.project
===================================================================
--- jbossxb/branches/split/staxparser/trunk/.project (rev 0)
+++ jbossxb/branches/split/staxparser/trunk/.project 2010-06-11 15:24:37 UTC (rev 4498)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jbossxb-staxparser</name>
+ <comment>JBoss XML Binding STAX parser</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: jbossxb/branches/split/staxparser/trunk/pom.xml
===================================================================
--- jbossxb/branches/split/staxparser/trunk/pom.xml (rev 0)
+++ jbossxb/branches/split/staxparser/trunk/pom.xml 2010-06-11 15:24:37 UTC (rev 4498)
@@ -0,0 +1,147 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>5</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jbossxb-staxparser</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>JBoss XML Binding</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss XML Binding</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/common/jbossxb/branches/split/jbossxb-staxparser/trunk</connection>
+ </scm>
+ <build>
+ <finalName>jbossxb-staxparser</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <!-- The tagBase property is needed during the release process so that the maven release plugin
+ will create the release tag in the appropriate location. -->
+ <tagBase>https://svn.jboss.org/repos/common/jbossxb/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- the tessuite will be run twice.
+ the first/default execution will run with the default xb configuration
+ if there are failures, the next execution won't be run -->
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <!-- this execution will run with xb.builder.useUnorderedSequence=true
+ the reports from the previous testsuite run will be overriden
+ which is ok, since if the previous execution fails, this execution shouldn't start -->
+ <id>unordered-sequence-true-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertySequenceUnmarshallingTestCase.java</exclude> <!-- unordered sequence makes it JBXB-193 -->
+ <exclude>org/jboss/test/xb/builder/repeatableterms/test/RepeatableTermsUnitTestCase.java</exclude>
+
+ <!-- below are the tests that don't depend on the setting -->
+ <exclude>org/jboss/test/xb/validator/test/BasicBindingValidatorUnitTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>xb.builder.useUnorderedSequence</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ <execution>
+ <!-- this execution will run with xb.builder.repeatableParticleHandlers=false -->
+ <id>repeatable-handlers-false-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludes>
+ <exclude>org/jboss/test/xml/RepeatedElementsUnitTestCase.java</exclude> <!-- JBXB-88 -->
+ <exclude>org/jboss/test/xb/builder/object/type/jbossxmlmodelgroup/test/RepeatablePropertyAllUnmarshallingTestCase.java</exclude> <!-- JBXB-193 -->
+ <!-- below are the tests that don't depend on the setting -->
+ <exclude>org/jboss/test/xb/validator/test/BasicBindingValidatorUnitTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>xb.builder.repeatableParticleHandlers</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb-core</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.1.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
\ No newline at end of file
Added: jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java
===================================================================
--- jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java (rev 0)
+++ jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/JBossXBParserFactoryImpl.java 2010-06-11 15:24:37 UTC (rev 4498)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.xb.binding.parser;
+
+import org.jboss.xb.binding.parser.stax.StaxJBossXBParser;
+
+/**
+ * A JBossXBParserFactoryImpl.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossXBParserFactoryImpl implements JBossXBParserFactory
+{
+ @Override
+ public JBossXBParser createParser()
+ {
+ return new StaxJBossXBParser();
+ }
+}
Added: jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/stax/StaxJBossXBParser.java
===================================================================
--- jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/stax/StaxJBossXBParser.java (rev 0)
+++ jbossxb/branches/split/staxparser/trunk/src/main/java/org/jboss/xb/binding/parser/stax/StaxJBossXBParser.java 2010-06-11 15:24:37 UTC (rev 4498)
@@ -0,0 +1,512 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.xb.binding.parser.stax;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLResolver;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.Source;
+
+import org.jboss.xb.binding.AttributesImpl;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.JBossXBRuntimeException;
+import org.jboss.xb.binding.parser.JBossXBParser;
+import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+/**
+ * A StaxJBossXBParser.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class StaxJBossXBParser implements JBossXBParser
+{
+
+ private static final Attributes EMPTY_ATTRS = new Attributes()
+ {
+ @Override
+ public int getIndex(String name)
+ {
+ return -1;
+ }
+
+ @Override
+ public int getIndex(String uri, String localName)
+ {
+ return -1;
+ }
+
+ @Override
+ public int getLength()
+ {
+ return 0;
+ }
+
+ @Override
+ public String getLocalName(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getQName(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getType(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getType(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public String getType(String uri, String localName)
+ {
+ return null;
+ }
+
+ @Override
+ public String getURI(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getValue(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getValue(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public String getValue(String uri, String localName)
+ {
+ return null;
+ }
+ };
+
+ private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+/* public StaxJBossXBParser()
+ {
+ System.out.println(inputFactory.getProperty(XMLInputFactory.IS_VALIDATING));
+ System.out.println(inputFactory.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE));
+ System.out.println(inputFactory.getProperty(XMLInputFactory.IS_COALESCING));
+ System.out.println(inputFactory.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES));
+ System.out.println(inputFactory.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES));
+ System.out.println(inputFactory.getProperty(XMLInputFactory.SUPPORT_DTD));
+ }
+*/
+ @Override
+ public void parse(final String source, ContentHandler handler) throws JBossXBException
+ {
+ try
+ {
+ XMLEventReader stream = inputFactory.createXMLEventReader(new Source()
+ {
+ @Override
+ public String getSystemId()
+ {
+ return source;
+ }
+
+ @Override
+ public void setSystemId(String systemId)
+ {
+ throw new UnsupportedOperationException();
+ }
+ });
+ parse(handler, stream);
+ }
+ catch (FactoryConfigurationError e)
+ {
+ throw new JBossXBException("Failed to create an instance of XMLStreamReader", e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new JBossXBException("Failed to parse XML stream", e);
+ }
+ catch(Throwable e)
+ {
+ throw new JBossXBException("Failed to parse source: ", e);
+ }
+ }
+
+ @Override
+ public void parse(InputStream is, ContentHandler handler) throws JBossXBException
+ {
+ try
+ {
+ XMLEventReader stream = inputFactory.createXMLEventReader(is);
+ parse(handler, stream);
+ }
+ catch (FactoryConfigurationError e)
+ {
+ throw new JBossXBException("Failed to create an instance of XMLStreamReader", e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new JBossXBException("Failed to parse XML stream", e);
+ }
+ catch(Throwable e)
+ {
+ throw new JBossXBException("Failed to parse source: ", e);
+ }
+ }
+
+ @Override
+ public void parse(Reader reader, ContentHandler handler) throws JBossXBException
+ {
+ try
+ {
+ XMLEventReader stream = inputFactory.createXMLEventReader(reader);
+ parse(handler, stream);
+ }
+ catch (FactoryConfigurationError e)
+ {
+ throw new JBossXBException("Failed to create an instance of XMLStreamReader", e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new JBossXBException("Failed to parse XML stream", e);
+ }
+ catch(Throwable e)
+ {
+ throw new JBossXBException("Failed to parse source: ", e);
+ }
+ }
+
+ @Override
+ public void parse(InputSource source, ContentHandler handler) throws JBossXBException
+ {
+ InputStream bs = source.getByteStream();
+ if(bs != null)
+ {
+ parse(bs, handler);
+ return;
+ }
+
+ Reader cs = source.getCharacterStream();
+ if(cs != null)
+ {
+ parse(cs, handler);
+ return;
+ }
+
+ String systemId = source.getSystemId();
+ if(systemId == null)
+ throw new JBossXBRuntimeException("None of ByteStream, CharacterStream, systemId are available through the instance of InputSource.");
+ parse(systemId, handler);
+ }
+
+ @Override
+ public void setEntityResolver(final EntityResolver entityResolver) throws JBossXBException
+ {
+ inputFactory.setXMLResolver(new XMLResolver()
+ {
+ @Override
+ public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace)
+ throws XMLStreamException
+ {
+ try
+ {
+ return entityResolver.resolveEntity(publicID, systemID);
+ }
+ catch (Exception e)
+ {
+ throw new JBossXBRuntimeException("Failed to resolve publicId=" + publicID +
+ ", systemId=" + systemID +
+ ", baseURI=" + baseURI +
+ ", namespace=" + namespace, e);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void setFeature(String name, boolean value)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setProperty(String name, Object value)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ private void parse(ContentHandler handler, final XMLEventReader stream) throws XMLStreamException
+ {
+ while (stream.hasNext())
+ {
+ XMLEvent event = stream.nextEvent();
+/*
+ switch(event)
+ {
+ case XMLStreamConstants.ATTRIBUTE:
+ System.out.println("attribute");
+ break;
+ case XMLStreamConstants.CDATA:
+ System.out.println("cdata");
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ System.out.println("characters");
+ break;
+ case XMLStreamConstants.COMMENT:
+ System.out.println("comment");
+ break;
+ case XMLStreamConstants.DTD:
+ System.out.println("dtd");
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ System.out.println("end doc");
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ System.out.println("end element " + stream.getLocalName());
+ break;
+ case XMLStreamConstants.ENTITY_DECLARATION:
+ System.out.println("entity dec");
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ System.out.println("entity ref");
+ break;
+ case XMLStreamConstants.NAMESPACE:
+ System.out.println("namespace");
+ break;
+ case XMLStreamConstants.NOTATION_DECLARATION:
+ System.out.println("notation");
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ System.out.println("pi");
+ break;
+ case XMLStreamConstants.SPACE:
+ System.out.println("space");
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ System.out.println("start doc");
+ break;
+ case XMLStreamConstants.START_ELEMENT:
+ System.out.println("start element " + stream.getLocalName());
+ break;
+ default:
+ throw new IllegalStateException("Unknown event " + event);
+ }
+*/
+/* if (event == XMLStreamConstants.START_DOCUMENT)
+ {
+ }
+ else */if (event.isStartElement())
+ {
+ //System.out.println("start " + stream.getLocalName());
+
+ final StartElement start = (StartElement)event;
+ Iterator<Namespace> i = start.getNamespaces();
+ while(i.hasNext())
+ {
+ Namespace declaredNs = i.next();
+ String ns = declaredNs.getNamespaceURI();
+ if(ns == null)
+ ns = "";
+ String prefix = declaredNs.getPrefix();
+ if(prefix == null)
+ prefix = "";
+ handler.startPrefixMapping(prefix, ns);
+ }
+
+ Attributes attrs = EMPTY_ATTRS;
+ Iterator<Attribute> eAttrs = start.getAttributes();
+ if(eAttrs.hasNext())
+ {
+ final List<Attribute> attrList = new ArrayList<Attribute>();
+ while(eAttrs.hasNext())
+ attrList.add(eAttrs.next());
+
+ attrs = new Attributes()
+ {
+ @Override
+ public int getIndex(String name)
+ {
+ return getIndex(null, name);
+ }
+
+ @Override
+ public int getIndex(String uri, String localName)
+ {
+ return -1;
+ }
+
+ @Override
+ public int getLength()
+ {
+ return attrList.size();
+ }
+
+ @Override
+ public String getLocalName(int index)
+ {
+ return attrList.get(index).getName().getLocalPart();
+ }
+
+ @Override
+ public String getQName(int index)
+ {
+ return null;
+ }
+
+ @Override
+ public String getType(int index)
+ {
+ return attrList.get(index).getDTDType();
+ }
+
+ @Override
+ public String getType(String name)
+ {
+ return getType(null, name);
+ }
+
+ @Override
+ public String getType(String uri, String localName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getURI(int index)
+ {
+ return attrList.get(index).getName().getNamespaceURI();
+ }
+
+ @Override
+ public String getValue(int index)
+ {
+ return attrList.get(index).getValue();
+ }
+
+ @Override
+ public String getValue(String name)
+ {
+ return getValue(null, name);
+ }
+
+ @Override
+ public String getValue(String uri, String localName)
+ {
+ Attribute attr = start.getAttributeByName(new QName(uri, localName));
+ if(attr == null)
+ return null;
+ return attr.getValue();
+ }
+ };
+ }
+
+ String ns = start.getName().getNamespaceURI();
+ if(ns == null)
+ ns = "";
+ handler.startElement(ns, start.getName().getLocalPart(), null, attrs);
+ }
+// else if (event == XMLStreamConstants.ATTRIBUTE)
+// {
+// }
+ else if (event.isCharacters())
+ {
+ Characters chars = (Characters) event;
+ handler.characters(chars.getData().toCharArray(), 0, chars.getData().length());
+ }
+// else if (event == XMLStreamConstants.COMMENT)
+// {
+// //System.out.println("Comment Text:" + stream.getText());
+// }
+// else if (event == XMLStreamConstants.END_DOCUMENT)
+// {
+// }
+ else if (event.isEndElement())
+ {
+ EndElement end = (EndElement) event;
+ String ns = end.getName().getNamespaceURI();
+ if(ns == null)
+ ns = "";
+ handler.endElement(ns, end.getName().getLocalPart(), null);
+ Iterator<Namespace> i = end.getNamespaces();
+ while(i.hasNext())
+ {
+ Namespace declaredNs = i.next();
+ String prefix = declaredNs.getPrefix();
+ if(prefix == null)
+ prefix = "";
+ handler.endPrefixMapping(prefix);
+ }
+ }
+ else if(event instanceof DTD)
+ {
+ DTD dtd = (DTD) event;
+ System.out.println("DTD: " + dtd.getDocumentTypeDeclaration());
+ }
+// if (event == XMLStreamConstants.PROCESSING_INSTRUCTION)
+// {
+// System.out.println("PI Target:" + stream.getPITarget());
+// System.out.println("PI Data:" + stream.getPIData());
+// }
+// if (event == XMLStreamConstants.SPACE)
+// {
+// System.out.println("Event Type: SPACE");
+// System.out.println("Text:" + stream.getText());
+//
+// }
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list