private void generateResourceManagerElement(AttributesImpl atts) throws SAXException { handler.startElement("", RESOURCE_MANAGER, RESOURCE_MANAGER, atts); handler.endElement("", RESOURCE_MANAGER, RESOURCE_MANAGER); }
/** * Generates XML for a <code>String</code> */ private void generate(String s) throws SAXException { handler.startElement("", STRING, STRING, EMPTY); handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", STRING, STRING); }
/** * Generates XML for a locator */ private void generateLocator(DistributionLocatorConfig config) throws SAXException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", PORT, "", String.valueOf(config.getPort())); handler.startElement("", LOCATOR, LOCATOR, atts); generateEntityConfig(config); handler.endElement("", LOCATOR, LOCATOR); }
@Test public void marshalSAXResult() throws Exception { ContentHandler contentHandler = mock(ContentHandler.class); SAXResult result = new SAXResult(contentHandler); marshaller.marshal(flights, result); InOrder ordered = inOrder(contentHandler); ordered.verify(contentHandler).setDocumentLocator(isA(Locator.class)); ordered.verify(contentHandler).startDocument(); ordered.verify(contentHandler).startPrefixMapping("", "http://samples.springframework.org/flight"); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flights"), eq("flights"), isA(Attributes.class)); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flight"), eq("flight"), isA(Attributes.class)); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("number"), eq("number"), isA(Attributes.class)); ordered.verify(contentHandler).characters(isA(char[].class), eq(0), eq(2)); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "number", "number"); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flight", "flight"); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flights", "flights"); ordered.verify(contentHandler).endPrefixMapping(""); ordered.verify(contentHandler).endDocument(); }
public void endStartTag() throws SAXException { NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(ns!=null) { int sz = ns.count(); for( int i=0; i<sz; i++ ) { String p = ns.getPrefix(i); String uri = ns.getNsUri(i); if(uri.length()==0 && ns.getBase()==1) continue; // no point in defining xmlns='' on the root out.startPrefixMapping(p,uri); } } out.startElement(elementNsUri,elementLocalName,elementQName,atts); }
inDocHandler.startElement("", "classes", "classes", new AttributesImpl()); inDocHandler.endElement("", "classes", "classes"); inDocHandler.endDocument();
if (contentHandler != null) { attAdapter.setAttributeList(qAtts); contentHandler.startElement("", "", qName.intern(), attAdapter); contentHandler.startPrefixMapping(prefix, value); atts.addAttribute (nsSupport.XMLNS, prefix, attQName.intern(), type, value); else atts.addAttribute ("", "", attQName.intern(), type, value); atts.addAttribute(attName[0], attName[1], attName[2], type, value); } catch (SAXException e) { contentHandler.startElement(name[0], name[1], name[2], atts);
/** * Encode an AttributeType whose value type is a Boolean. * * @param attribute * @throws SAXException */ protected void encodeBoolean(AttributeDescriptor attribute) throws SAXException { AttributesImpl atts = createStandardAttributes(attribute); atts.addAttribute("", "type", "type", "", "xs:boolean"); contentHandler.startElement(SCHEMA_NS, "element", "xs:element", atts); contentHandler.endElement(SCHEMA_NS, "element", "xs:element"); }
protected final ContentHandler mockContentHandler() throws Exception { ContentHandler contentHandler = mock(ContentHandler.class); willAnswer(new CopyCharsAnswer()).given(contentHandler).characters(any(char[].class), anyInt(), anyInt()); willAnswer(new CopyCharsAnswer()).given(contentHandler).ignorableWhitespace(any(char[].class), anyInt(), anyInt()); willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { invocation.getArguments()[3] = new AttributesImpl((Attributes) invocation.getArguments()[3]); return null; } }).given(contentHandler).startElement(anyString(), anyString(), anyString(), any(Attributes.class)); return contentHandler; }
public void generate() throws IOException, SAXException, ProcessingException { contentHandler.startDocument(); contentHandler.startPrefixMapping(FormsConstants.INSTANCE_PREFIX, FormsConstants.INSTANCE_NS); Attributes formAtts = this.config.getFormAttributes(); contentHandler.startElement(FormsConstants.INSTANCE_NS, FORM_GENERATED_EL, FormsConstants.INSTANCE_PREFIX_COLON +FORM_GENERATED_EL, formAtts); Form form = config.findForm(); form.generateSaxFragment(contentHandler, Locale.US); contentHandler.endElement(FormsConstants.INSTANCE_NS, FORM_GENERATED_EL, FormsConstants.INSTANCE_PREFIX_COLON +FORM_GENERATED_EL); contentHandler.endPrefixMapping(FormsConstants.INSTANCE_PREFIX); contentHandler.endDocument(); } }
/** * Generates the <code>serializer-registration</code> element. * */ private void generateSerializerRegistration() throws SAXException { final SerializerCreation sc = this.creation.getSerializerCreation(); if (sc == null) { return; } handler.startElement("", TOP_SERIALIZER_REGISTRATION, TOP_SERIALIZER_REGISTRATION, EMPTY); for (Class c : sc.getSerializerRegistrations()) { handler.startElement("", SERIALIZER_REGISTRATION, SERIALIZER_REGISTRATION, EMPTY); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(c.getName().toCharArray(), 0, c.getName().length()); handler.endElement("", CLASS_NAME, CLASS_NAME); handler.endElement("", SERIALIZER_REGISTRATION, SERIALIZER_REGISTRATION); } for (Map.Entry<Class, Integer> e : sc.getInstantiatorRegistrations().entrySet()) { Class c = e.getKey(); Integer i = e.getValue(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", ID, "", i.toString()); handler.startElement("", INSTANTIATOR_REGISTRATION, INSTANTIATOR_REGISTRATION, atts); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(c.getName().toCharArray(), 0, c.getName().length()); handler.endElement("", CLASS_NAME, CLASS_NAME); handler.endElement("", INSTANTIATOR_REGISTRATION, INSTANTIATOR_REGISTRATION); } handler.endElement("", TOP_SERIALIZER_REGISTRATION, TOP_SERIALIZER_REGISTRATION); }
private void generateBackupFile(File file) throws SAXException { handler.startElement("", BACKUP, BACKUP, EMPTY); handler.characters(file.getPath().toCharArray(), 0, file.getPath().length()); handler.endElement("", BACKUP, BACKUP); }
@Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { handler.startDocument(); handler.startPrefixMapping("", XHTML); handler.startElement(XHTML, "html", "html", EMPTY_ATTRIBUTES); handler.startElement(XHTML, "head", "head", EMPTY_ATTRIBUTES); handler.startElement(XHTML, "title", "head", EMPTY_ATTRIBUTES); handler.characters(TITLE, 0, TITLE.length); handler.endElement(XHTML, "title", "head"); handler.endElement(XHTML, "head", "head"); handler.startElement(XHTML, "body", "body", EMPTY_ATTRIBUTES); char[] body = new char[charsToWrite]; for (int i = 0; i < charsToWrite; i++) { body[i] = 'a'; } handler.characters(body, 0, body.length); handler.endElement(XHTML, "body", "body"); handler.endElement(XHTML, "html", "html"); handler.endDocument(); } }
/** * Generates XML for locators in the distributed system */ private void generateDiscovery() throws SAXException { handler.startElement("", LOCATORS, LOCATORS, EMPTY); generateLocators(); handler.endElement("", LOCATORS, LOCATORS); }
/** * Writes the angle bracket if the element open tag is not finished. * * @throws SAXException If thrown by the content handler */ private void deNude() throws SAXException { if (this.isNude) { indent(); Element elt = peekElement(); // report the prefix mapping if (elt.mappings != null) { for (int i = 0; i < elt.mappings.size(); i++) { PrefixMapping pm = elt.mappings.get(i); this.handler.startPrefixMapping(pm.prefix, pm.uri); } } this.handler.startElement(elt.uri, elt.name, getQName(elt.uri, elt.name), this.attributes); this.attributes = new AttributesImpl(); if (this.indent && elt.hasChildren) { newLine(); } this.isNude = false; } }
private void startParagraph(String styleName) throws SAXException { if (pDepth == 0) { handler.startElement(XHTML, "p", "p", EMPTY_ATTRIBUTES); if (styleName != null) { currTextStyle = paragraphTextStyleMap.get(styleName); } hasWrittenStartStyleTags = false; } else { handler.characters(SPACE, 0, SPACE.length); } pDepth++; }
/** * Generate XML for FixedPartitionAttribute element in PartitionedRegion Attributes */ private void generateFixedPartitionAttributes(String kind, List<FixedPartitionAttributes> allStaticAttrs) throws SAXException { for (FixedPartitionAttributes attr : allStaticAttrs) { AttributesImpl sAtts = new AttributesImpl(); sAtts.addAttribute("", "", PARTITION_NAME, "", attr.getPartitionName()); sAtts.addAttribute("", "", IS_PRIMARY, "", String.valueOf(attr.isPrimary())); sAtts.addAttribute("", "", NUM_BUCKETS, "", String.valueOf(attr.getNumBuckets())); handler.startElement("", kind, kind, sAtts); handler.endElement("", kind, kind); } }
/** * Generates XML for key constraints * * @param element The kind of element to generate (KEY_CONSTRAINT or VALUE_CONSTRAINT). */ private void generate(Class c, String element) throws SAXException { if (c != null) { handler.startElement("", element, element, EMPTY); String className = c.getName(); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", element, element); } }
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException { String nsUri = av.nsUri; String ln = av.faultDetailTag.getLocalPart(); h.startPrefixMapping("",nsUri); h.startElement(nsUri,ln,ln,EMPTY_ATTS); h.startElement(nsUri,wrapper,wrapper,EMPTY_ATTS); h.characters(problemValue.toCharArray(),0,problemValue.length()); h.endElement(nsUri,wrapper,wrapper); h.endElement(nsUri,ln,ln); } }
/** * Generates XML for a region entry */ private void generate(Region.Entry entry) throws SAXException { if ((entry == null)) { return; } handler.startElement("", ENTRY, ENTRY, EMPTY); handler.startElement("", KEY, KEY, EMPTY); generate(entry.getKey()); handler.endElement("", KEY, KEY); handler.startElement("", VALUE, VALUE, EMPTY); generate(entry.getValue()); handler.endElement("", VALUE, VALUE); handler.endElement("", ENTRY, ENTRY); }