XMLStreamUtils { public static QName asRelaxedQName( XMLStreamReader xmlStream, String s ) { try { return asQName( xmlStream, s ); } catch ( XMLParsingException e ) { Matcher m = Pattern.compile( "\\{(http: if ( m.find() ) { return new QName( m.group( 1 ), m.group( 2 ) ); } else { throw e; } } }  static final String getCurrentEventInfo( XMLStreamReader xmlStream ); static void skipElement( XMLStreamReader xmlStream ); static URL resolve( String url, XMLStreamReader in ); static QName asQName( XMLStreamReader xmlStream, String s ); static QName asRelaxedQName( XMLStreamReader xmlStream, String s ); static void skipStartDocument( XMLStreamReader xmlStream ); static String getAttributeValue( XMLStreamReader xmlStream, String localName ); static String getRequiredAttributeValue( XMLStreamReader xmlStream, String localName ); static String getRequiredAttributeValue( XMLStreamReader xmlStream, String namespaceURI, String localName ); static QName getRequiredAttributeValueAsQName( XMLStreamReader xmlStream, String namespaceURI,
                                                          String localName ); static QName getAttributeValueAsQName( XMLStreamReader xmlStream, String namespaceURI, String localName,
                                                  QName defaultValue ); static boolean getElementTextAsBoolean( XMLStreamReader xmlStream ); static int getElementTextAsInteger( XMLStreamReader xmlStream ); static BigInteger getElementTextAsBigInteger( XMLStreamReader xmlStream ); static double getElementTextAsDouble( XMLStreamReader xmlStream ); static boolean getElementTextAsBoolean( XMLStreamReader reader, QName elementName, boolean defaultValue,
                                                   boolean nextElemOnSucces ); static boolean getAttributeValueAsBoolean( XMLStreamReader xmlStream, String namespaceURI, String localName,
                                                      boolean defaultValue ); static QName getElementTextAsQName( XMLStreamReader xmlStream ); static QName getElementTextAsRelaxedQName( XMLStreamReader xmlStream ); static void requireStartElement( XMLStreamReader xmlStream, QName elName ); static void requireStartElement( XMLStreamReader xmlStream, Collection<QName> expectedElements ); static void require( XMLStreamReader xmlStream, int eventType ); static void requireNextTag( XMLStreamReader xmlStream, int eventType ); static final String getEventTypeString( int eventType ); static boolean getRequiredAttributeValueAsBoolean( XMLStreamReader xmlStream, String namespaceURI,
                                                              String localName ); static String getText( XMLStreamReader reader, QName elemName, String defaultText, boolean nextElemOnSucces ); static void skipToRequiredElement( XMLStreamReader reader, QName elementName ); static boolean skipToElementOnSameLevel( XMLStreamReader reader, QName elementName ); static void skipToRequiredElementOnSameLevel( XMLStreamReader reader, QName elementName ); static void skipRequiredElement( XMLStreamReader reader, QName elementName ); static String getRequiredText( XMLStreamReader reader, QName elementName, boolean nextElemOnSucces ); static String[] getSimpleUnboundedAsStrings( XMLStreamReader reader, QName name ); static int nextElement( XMLStreamReader xmlReader ); static double getElementTextAsDouble( XMLStreamReader reader, QName elementName, double defaultValue,
                                                 boolean nextElemOnSucces ); static int getElementTextAsInteger( XMLStreamReader reader, QName elementName, int defaultValue,
                                               boolean nextElemOnSucces ); static double getRequiredElementTextAsDouble( XMLStreamReader reader, QName elementName,
                                                         boolean nextElemOnSucces ); static int getRequiredElementTextAsInteger( XMLStreamReader reader, QName elementName,
                                                       boolean nextElemOnSucces ); static boolean moveReaderToFirstMatch( XMLStreamReader reader, QName elementName ); static boolean moveReaderToFirstMatch( XMLStreamReader reader, Collection<QName> alowedElements ); static Map<QName, String> getAttributes( XMLStreamReader reader ); static Document getAsDocument( XMLStreamReader xmlStreamReader ); static XMLStreamReader getAsXmlStrem( OMElement omElement ); static void copy( XMLStreamWriter writer, XMLStreamReader reader ); static StreamBufferStore serialize( XMLStreamReader reader ); static void writeNamespaceIfNotBound( XMLStreamWriter xmlStream, String prefix, String nsUri ); static void closeQuietly( XMLStreamReader xmlReader );  }
@Test public void testAsRelaxedQName() throws XMLStreamException, FactoryConfigurationError, IOException { URL url = XMLStreamUtilsTest.class.getResource( "xmlstreamutils.xml" ); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader( url.openStream() ); XMLStreamUtils.skipToRequiredElement( reader, new QName( "http: QName name = XMLStreamUtils.getElementTextAsRelaxedQName( reader ); assertEquals( "Namespace not detected properly", "http: assertEquals( "Local name not detected properly", "SGID500_ZipCodes", name.getLocalPart() ); }