Example usage for javax.xml.stream XMLStreamReader standaloneSet

List of usage examples for javax.xml.stream XMLStreamReader standaloneSet

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamReader standaloneSet.

Prototype

public boolean standaloneSet();

Source Link

Document

Checks if standalone was set in the document

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    File file = new File("yourXML.xml");
    FileInputStream inputStream = new FileInputStream(file);
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    XMLStreamReader reader = inputFactory.createXMLStreamReader(inputStream);

    System.out.println(reader.getVersion());
    System.out.println(reader.isStandalone());
    System.out.println(reader.standaloneSet());
    System.out.println(reader.getEncoding());
    System.out.println(reader.getCharacterEncodingScheme());

    parseRestOfDocument(reader);/*from  w  w w . j a va  2 s  . c o m*/
}

From source file:StAXStreamTreeViewer.java

private void addStartDocumentNodes(XMLStreamReader reader, DefaultMutableTreeNode current) {
    DefaultMutableTreeNode version = new DefaultMutableTreeNode(reader.getVersion());
    current.add(version);//w w  w  .j  a v  a  2s  .co m

    DefaultMutableTreeNode standalone = new DefaultMutableTreeNode(reader.isStandalone());
    current.add(standalone);

    DefaultMutableTreeNode standaloneSet = new DefaultMutableTreeNode(reader.standaloneSet());
    current.add(standaloneSet);

    DefaultMutableTreeNode encoding = new DefaultMutableTreeNode(reader.getEncoding());
    current.add(encoding);

    DefaultMutableTreeNode declaredEncoding = new DefaultMutableTreeNode(reader.getCharacterEncodingScheme());
    current.add(declaredEncoding);
}