Java XML Namespace printNamespaces(XMLStreamReader xmlr)

Here you can find the source of printNamespaces(XMLStreamReader xmlr)

Description

print Namespaces

License

Open Source License

Declaration

protected static void printNamespaces(XMLStreamReader xmlr) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 UNIT Information Technologies R&D Ltd
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   w w w. j  a v  a 2s  .  c  o  m
 *     Ferhat Erata - initial API and implementation
 *     H. Emre Kirmizi - initial API and implementation
 *     Serhat Celik - initial API and implementation
 *     U. Anil Ozturk - initial API and implementation
 *******************************************************************************/

import javax.xml.stream.XMLStreamReader;

public class Main {
    protected static void printNamespaces(XMLStreamReader xmlr) {
        for (int i = 0; i < xmlr.getNamespaceCount(); i++) {
            printNamespace(xmlr, i);
        }
    }

    protected static void printNamespace(XMLStreamReader xmlr, int index) {
        String prefix = xmlr.getNamespacePrefix(index);
        String uri = xmlr.getNamespaceURI(index);
        System.out.print(" ");
        if (prefix == null)
            System.out.print("xmlns='" + uri + "'");
        else
            System.out.print("xmlns:" + prefix + "='" + uri + "'");
    }
}

Related

  1. getXmlSchemaNamespace(Class clazz)
  2. isNamespaceAware()
  3. isValidFragment(final Object obj, final String namespace, final String localPart)
  4. logWriter(Logger logger, String msg, XMLStreamWriter writer, String namespaceURI)
  5. printNamespace(XMLStreamReader xmlr, int index, StringBuffer result)
  6. readXML(InputStream input, boolean isNamespaceAware)
  7. stringToDoc(String s, boolean nameSpaceAware)
  8. writeNamespace(XMLStreamWriter out, String prefix, String namespaceURI)
  9. writeNamespace(XMLStreamWriter writer, String prefix, String namespaceURI)