use of org.xml.sax.ext.Attributes2Impl in project intellij-community by JetBrains.
the class Psi2SaxAdapter method visitXmlTag.
@Override
public void visitXmlTag(XmlTag tag) {
try {
setLocation(tag);
final Map<String, String> map = tag.getLocalNamespaceDeclarations();
final String[] prefixes = map.keySet().toArray(new String[map.size()]);
for (String prefix : prefixes) {
myHandler.startPrefixMapping(prefix, map.get(prefix));
}
final Attributes2Impl atts = new Attributes2Impl();
final XmlAttribute[] xmlAttributes = tag.getAttributes();
for (XmlAttribute attribute : xmlAttributes) {
final String s = attribute.getName();
if (!"xmlns".equals(s) && !s.startsWith("xmlns:")) {
final String uri = attribute.getNamespace();
atts.addAttribute(s.contains(":") ? uri : "", attribute.getLocalName(), s, "PCDATA", attribute.getValue());
}
}
final String namespace = tag.getNamespace();
final String localName = tag.getLocalName();
final String name = tag.getName();
myHandler.startElement(namespace, localName, name, atts);
PsiElement child = tag.getFirstChild();
while (child != null) {
child.accept(this);
child = child.getNextSibling();
}
myHandler.endElement(namespace, localName, name);
for (int i = prefixes.length - 1; i >= 0; i--) {
String prefix = prefixes[i];
myHandler.endPrefixMapping(prefix);
}
} catch (SAXException e) {
throw new ParseError(e);
}
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class XMLPackagerTest method onSetup.
@Before
public void onSetup() throws ISOException, NoSuchFieldException {
// PrintStream p = new PrintStream(new ByteArrayOutputStream())
xMLPackager = new XMLPackager();
atts = new Attributes2Impl();
logger = new Logger();
logger.addListener(new SimpleLogListener());
isoMsg = xMLPackager.createISOMsg();
xMLPackager.setLogger(logger, xMLPackager.getClass().getName());
isoMsg.setPackager(xMLPackager);
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class GenericValidatingPackagerTest method testGenericValidatorContentHandlerStartElementThrowsSAXException2.
@Test
public void testGenericValidatorContentHandlerStartElementThrowsSAXException2() throws Throwable {
GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler();
Attributes atts = new Attributes2Impl();
try {
genericValidatorContentHandler.startElement("testGenericValidatorContentHandlerNamespaceURI", null, "testGenericValidatorContentHandlerQName", atts);
fail("Expected SAXException to be thrown");
} catch (SAXException ex) {
assertNull("ex.getMessage()", ex.getMessage());
assertNull("ex.getException().getMessage()", ex.getException().getMessage());
}
}
Aggregations