@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); if (state.getTarget() == null) state.setTarget(new State(context)); State s = (State) state.getTarget(); try { s.declarePrefixes(context, context.getNewlyDeclaredPrefixes()); s.handler.startElement(ea.uri, ea.local, ea.getQname(), ea.atts); } catch (SAXException e) { context.handleError(e); throw e; } }
private static void serializeEntry(TransformerHandler hd, Entry entry) throws SAXException { AttributesImpl entryAttributes = new AttributesImpl(); for (Iterator<String> it = entry.getAttributes().iterator(); it.hasNext();) { String key = it.next(); entryAttributes.addAttribute("", "", key, "", entry.getAttributes().getValue(key)); } hd.startElement("", "", ENTRY_ELEMENT, entryAttributes); StringList tokens = entry.getTokens(); for (String token : tokens) { hd.startElement("", "", TOKEN_ELEMENT, new AttributesImpl()); hd.characters(token.toCharArray(), 0, token.length()); hd.endElement("", "", TOKEN_ELEMENT); } hd.endElement("", "", ENTRY_ELEMENT); } }
hd.startElement("", "", DICTIONARY_ELEMENT, dictionaryAttributes);
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); if (state.getTarget() == null) state.setTarget(new State(context)); State s = (State) state.getTarget(); try { s.declarePrefixes(context, context.getNewlyDeclaredPrefixes()); s.handler.startElement(ea.uri, ea.local, ea.getQname(), ea.atts); } catch (SAXException e) { context.handleError(e); throw e; } }
public void startElement(String name, String... attributeNameValues) throws SAXException { AttributesImpl atts = null; if (attributeNameValues != null && attributeNameValues.length > 0) { if (attributeNameValues.length % 2 == 1) throw new IllegalArgumentException("Even number of attribute name/name arguments required"); atts = new AttributesImpl(); for (int i = 0; i < attributeNameValues.length; i += 2) addAttribute(attributeNameValues[i], attributeNameValues[i+1], atts); } handler.startElement("", "", name, atts); }
@Override protected void startArray(String name) { try { hd.startElement("", "", name, null); } catch (SAXException e) { throw Exceptions.handle(e); } }
public void startElement(String name, Map<String, String> attributes) throws SAXException { AttributesImpl atts = null; if (attributes != null) { atts = new AttributesImpl(); for (Map.Entry<String, String> entry : attributes.entrySet()) addAttribute(entry.getKey(), entry.getValue(), atts); } handler.startElement("", "", name, atts); }
void generateSuccessNode(int searchNodeId) { try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", "id", "CDATA", "" + searchNodeId); hdTree.startElement("", "", "succ", atts); hdTree.endElement("", "", "succ"); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * {@link ContentHandler} implementation. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { this.initContentHandler(); contentHandler.startElement(namespaceURI, localName, qName, atts); }
/** * Makes an childless element appear as {@code<foo />} instead of * {@code<foo></foo>} * @param element the element * @throws SAXException */ private void childless(Element element) throws SAXException { Attributes attributes = getElementAttributes(element); handler.startElement(element.getNamespaceURI(), "", element.getLocalName(), attributes); handler.endElement(element.getNamespaceURI(), "", element.getLocalName()); }
/** * Makes an childless element appear as {@code<foo />} instead of * {@code<foo></foo>} * @param element the element * @throws SAXException */ private void childless(Element element) throws SAXException { Attributes attributes = getElementAttributes(element); handler.startElement(element.getNamespaceURI(), "", element.getLocalName(), attributes); handler.endElement(element.getNamespaceURI(), "", element.getLocalName()); }
/** * Makes an childless element appear as {@code<foo />} instead of * {@code<foo></foo>} * @param element the element * @throws SAXException */ private void childless(Element element) throws SAXException { Attributes attributes = getElementAttributes(element); handler.startElement(element.getNamespaceURI(), "", element.getLocalName(), attributes); handler.endElement(element.getNamespaceURI(), "", element.getLocalName()); }
protected void writeSimpleTag(final String tagName, final String value, final AttributesImpl attributes) throws SAXException { handler.startElement("", "", tagName, attributes); if (value != null) handler.characters(value.toCharArray(), 0, value .length()); handler.endElement("", "", tagName); }
private void writeGraphStart(TransformerHandler handler, Graph<V, E> g) throws SAXException { // <graph> AttributesImpl attr = new AttributesImpl(); attr.addAttribute( "", "", "edgedefault", "CDATA", g.getType().isDirected() ? "directed" : "undirected"); handler.startElement("", "", "graph", attr); }
private void writeHeader(TransformerHandler handler) throws SAXException { handler.startPrefixMapping("xsi", "http://www.w3.org/2001/XMLSchema-instance"); handler.endPrefixMapping("xsi"); AttributesImpl attr = new AttributesImpl(); attr.addAttribute( "", "", "xsi:schemaLocation", "CDATA", "http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"); handler.startElement("http://graphml.graphdrawing.org/xmlns", "", "graphml", attr); }
private void writeElement(TransformerHandler th, String ns, String name, Attributes attrs, String textContent) throws SAXException { th.startElement(ns, name, name, attrs); if (textContent != null) { th.characters(textContent.toCharArray(), 0, textContent.length()); } th.endElement(ns, name, name); }
private void startArtifact(TransformerHandler saxHandler, Artifact artifact) throws SAXException { AttributesImpl artifactAttrs = new AttributesImpl(); artifactAttrs.addAttribute(null, "name", "name", "CDATA", artifact.getName()); artifactAttrs.addAttribute(null, "ext", "ext", "CDATA", artifact.getExt()); artifactAttrs.addAttribute(null, "type", "type", "CDATA", artifact.getType()); saxHandler.startElement(null, "artifact", "artifact", artifactAttrs); }
private void writeCacheLocationIfPresent(RepositoryCacheManager cache, TransformerHandler saxHandler, ArtifactDownloadReport artifact) throws SAXException { File archiveInCache = artifact.getLocalFile(); if (archiveInCache != null) { saxHandler.startElement(null, "cache-location", "cache-location", new AttributesImpl()); char[] archiveInCacheAsChars = archiveInCache.getPath().replace('\\', '/') .toCharArray(); saxHandler.characters(archiveInCacheAsChars, 0, archiveInCacheAsChars.length); saxHandler.endElement(null, "cache-location", "cache-location"); } }
private void writeRetrieveLocation(TransformerHandler saxHandler, String artifactDestPath) throws SAXException { artifactDestPath = removeLeadingPath(getProject().getBaseDir(), new File(artifactDestPath)); saxHandler.startElement(null, "retrieve-location", "retrieve-location", new AttributesImpl()); char[] artifactDestPathAsChars = artifactDestPath.replace('\\', '/').toCharArray(); saxHandler.characters(artifactDestPathAsChars, 0, artifactDestPathAsChars.length); saxHandler.endElement(null, "retrieve-location", "retrieve-location"); }
private void startModule(TransformerHandler saxHandler, IvyNode dependency) throws SAXException { AttributesImpl moduleAttrs = new AttributesImpl(); moduleAttrs.addAttribute(null, "organisation", "organisation", "CDATA", dependency .getModuleId().getOrganisation()); moduleAttrs.addAttribute(null, "name", "name", "CDATA", dependency.getModuleId().getName()); ResolvedModuleRevision moduleRevision = dependency.getModuleRevision(); moduleAttrs.addAttribute(null, "rev", "rev", "CDATA", moduleRevision.getId().getRevision()); moduleAttrs.addAttribute(null, "status", "status", "CDATA", moduleRevision.getDescriptor() .getStatus()); saxHandler.startElement(null, "module", "module", moduleAttrs); }