当前位置: 首页>>代码示例>>Java>>正文


Java XMLStreamException.printStackTrace方法代码示例

本文整理汇总了Java中javax.xml.stream.XMLStreamException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamException.printStackTrace方法的具体用法?Java XMLStreamException.printStackTrace怎么用?Java XMLStreamException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.stream.XMLStreamException的用法示例。


在下文中一共展示了XMLStreamException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startElement

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public void startElement(String uri, String name, String qName,
		Attributes atts) {

	try {
		isSalary = (uri.equals(ns) && name.equals("salary"));
		writer.writeStartElement(name);
		if (!(uri.equals(lastNamespace))) {
			lastNamespace = uri;
			writer.setDefaultNamespace(uri);				
			writer.writeDefaultNamespace(uri);
		}
		for (int i = 0; i < atts.getLength(); i++) {
			writer.writeAttribute(atts.getLocalName(i), atts.getValue(i));
		}
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:20,代码来源:Cut.java

示例2: writeRow

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
private void writeRow(final Row row, final XMLStreamWriter out, final Map<String, String> columns) {
	try {
		int rowIndex = row.getRowNum();
		out.writeStartElement("row");
		final String rowNum = String.valueOf(rowIndex);
		out.writeAttribute("row", rowNum);
		int count = 0;
		Iterator<Cell> cellIterator = row.iterator();
		while (cellIterator.hasNext()) {
			Cell cell = cellIterator.next();
			int columnIndex = cell.getColumnIndex();
			if (this.exportEmptyCells) {
				while (count < columnIndex) {
					this.writeAnyCell(rowIndex, count, null, out, columns);
					count++;
				}
			}
			this.writeCell(cell, out, columns);
			count++;
		}
		out.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:27,代码来源:E2xCmdline.java

示例3: dump

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
protected void dump(String header, Packet packet) {
    out.println("====["+name+":"+header+"]====");
    if(packet.getMessage()==null)
        out.println("(none)");
    else
        try {
            XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(out) {
                @Override
                public void close() {
                    // noop
                }
            });
            writer = createIndenter(writer);
            packet.getMessage().copy().writeTo(writer);
            writer.close();
        } catch (XMLStreamException e) {
            e.printStackTrace(out);
        }
    out.println("============");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DumpTube.java

示例4: testNestedNS

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Test
public void testNestedNS() throws Exception {

    final String VALID_XML = "<foo xmlns:xmli='http://www.w3.org/XML/1998/namespacei'><bar xmlns:xmli='http://www.w3.org/XML/1998/namespaceii'></bar></foo>";

    try {
        XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(VALID_XML));

        while (xsr.hasNext()) {
            xsr.next();
        }

        // expected success
    } catch (XMLStreamException e) {
        e.printStackTrace();

        Assert.fail("Wellformedness error is not expected: " + VALID_XML + ", " + e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DoubleXmlnsTest.java

示例5: testNestedXmlns

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Test
public void testNestedXmlns() throws Exception {

    final String VALID_XML = "<foo xmlns:xml='http://www.w3.org/XML/1998/namespace'><bar xmlns:xml='http://www.w3.org/XML/1998/namespace'></bar></foo>";

    try {
        XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(VALID_XML));

        while (xsr.hasNext()) {
            xsr.next();
        }

        // expected success
    } catch (XMLStreamException e) {
        e.printStackTrace();
        Assert.fail("Wellformedness error is not expected: " + VALID_XML + ", " + e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DoubleXmlnsTest.java

示例6: testCR6419687

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
/**
 * Test: 6419687 NPE in XMLEventWriterImpl.
 */
@Test
public void testCR6419687() {

    try {
        InputStream in = getClass().getResourceAsStream("ReaderToWriterTest.wsdl");
        OutputStream out = new FileOutputStream(USER_DIR + "ReaderToWriterTest-out.xml");

        XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(in);
        XMLEventWriter writer = XML_OUTPUT_FACTORY.createXMLEventWriter(out, "UTF-8");
        while (reader.hasNext()) {
            XMLEvent event = reader.nextEvent();
            writer.add(event);
        }
        reader.close();
        writer.close();
    } catch (XMLStreamException xmlStreamException) {
        xmlStreamException.printStackTrace();
        Assert.fail(xmlStreamException.toString());
    } catch (FileNotFoundException fileNotFoundException) {
        fileNotFoundException.printStackTrace();
        Assert.fail(fileNotFoundException.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ReaderToWriterTest.java

示例7: startDocument

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public void startDocument() throws SAXException {
	try {
		writer.writeStartDocument();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:9,代码来源:Cut.java

示例8: endDocument

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public void endDocument() throws SAXException {
	try {
		writer.writeEndDocument();
		writer.close();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:11,代码来源:Cut.java

示例9: endElement

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public void endElement(String uri, String name, String qName) {
	isSalary = false;
	try {
		writer.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:10,代码来源:Cut.java

示例10: characters

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public void characters(char[] ch, int start, int length) {
	try {
		if (isSalary) {
			String str = String.valueOf(ch, start, length);
			double salary = Double.parseDouble(str);
			writer.writeCharacters(String.valueOf(salary / 2));
		} else {
			writer.writeCharacters(String.valueOf(ch, start, length));
		}
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:15,代码来源:Cut.java

示例11: addStaxNamespacePrefix

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
private void addStaxNamespacePrefix(Entry<String, String> entry, ToXmlGenerator toXmlGenerator) {
  try {
    toXmlGenerator.getStaxWriter().setPrefix(entry.getKey(), entry.getValue());
  } catch (XMLStreamException e) {
    e.printStackTrace();
  }
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:8,代码来源:ExtendedXmlMapper.java

示例12: test

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Test
public void test() {
    try {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        for (int i = 0; i < 3; i++) {
            runReader(factory, i);
        }
    } catch (XMLStreamException xe) {
        xe.printStackTrace();
        Assert.fail(xe.getMessage());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:SkipDTDTest.java

示例13: readPayload

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Override
public XMLStreamReader readPayload() {
    try {
        return delegate.readPayload();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:MessageWrapper.java

示例14: setUpForNoRepair

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
private void setUpForNoRepair() {

        xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);

        // new Writer
        try {
            xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(byteArrayOutputStream);

        } catch (XMLStreamException xmlStreamException) {
            xmlStreamException.printStackTrace();
            Assert.fail(xmlStreamException.toString());
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:NamespaceTest.java

示例15: testDuplicateNSDeclaration

import javax.xml.stream.XMLStreamException; //导入方法依赖的package包/类
@Test
public void testDuplicateNSDeclaration() {

    // expect only 1 Namespace Declaration
    final String EXPECTED_OUTPUT = "<?xml version=\"1.0\" ?>" + "<ns1:foo" + " xmlns:ns1=\"http://example.com/\">" + "</ns1:foo>";

    // have XMLOutputFactory repair Namespaces
    XMLOutputFactory ofac = XMLOutputFactory.newInstance();
    ofac.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));

    // send output to a Stream
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    StreamResult sr = new StreamResult(buffer);
    XMLStreamWriter w = null;

    // write a duplicate Namespace Declaration
    try {
        w = ofac.createXMLStreamWriter(sr);
        w.writeStartDocument();
        w.writeStartElement("ns1", "foo", "http://example.com/");
        w.writeNamespace("ns1", "http://example.com/");
        w.writeNamespace("ns1", "http://example.com/");
        w.writeEndElement();
        w.writeEndDocument();
        w.close();
    } catch (XMLStreamException xmlStreamException) {
        xmlStreamException.printStackTrace();
        Assert.fail(xmlStreamException.toString());
    }

    // debugging output for humans
    System.out.println();
    System.out.println("actual:   \"" + buffer.toString() + "\"");
    System.out.println("expected: \"" + EXPECTED_OUTPUT + "\"");

    // are results as expected?
    Assert.assertEquals(EXPECTED_OUTPUT, buffer.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:DuplicateNSDeclarationTest.java


注:本文中的javax.xml.stream.XMLStreamException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。