|
|
Change By:
|
Michael Hauke
|
Steps to Reproduce:
|
package org.picketlink.common.util;
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter;
import junit.framework.Assert;
import org.junit.Test; import org.picketlink.common.exceptions.ConfigurationException; import org.picketlink.common.exceptions.ParsingException; import org.picketlink.common.exceptions.ProcessingException; import org.w3c.dom.DOMException;
public class StaxUtilTest {
@Test public void test() throws ProcessingException, XMLStreamException, ConfigurationException, ParsingException, DOMException, ParserConfigurationException, UnsupportedEncodingException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final XMLStreamWriter xmlStreamWriter = StaxUtil .getXMLStreamWriter(bos); StaxUtil.writeStartElement(xmlStreamWriter, See attachment " tr", "testroot", "urn:testroot"); StaxUtil dummy . writeNameSpace(xmlStreamWriter, zip " tr", "urn:testroot"); StaxUtil.writeDOMElement(xmlStreamWriter, DocumentBuilderFactory .newInstance().newDocumentBuilder().newDocument() .createElementNS("urn: for a test ", "t:test")); StaxUtil to reproduce the issue . writeEndElement(xmlStreamWriter); final String bosAsString = bos.toString("UTF-8"); System.out.println(bosAsString); DocumentUtil.getDocument(new ByteArrayInputStream(bos.toByteArray())); Assert.assertEquals( "<tr:testroot xmlns:tr=\"urn:testroot\"><t:test xmlns:t=\"urn:test\"></t:test></tr:testroot>", bosAsString); } }
|
|
Method writeDOMElement in class StaxUtil in package org.picketlink.common.util does not write a name space attribute for elements using a name space prefix. The resulting document cannot be parsed.
|
|
|
|