com.ctc.wstx.stax.WstxOutputFactory Java Examples
The following examples show how to use
com.ctc.wstx.stax.WstxOutputFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StaxMateFactory.java From setupmaker with Apache License 2.0 | 6 votes |
/** * Constructor * @param xml_file */ public StaxMateFactory(String xml_file) { if (xml_file != null) { WstxOutputFactory factory = new WstxOutputFactory(); factory.setProperty(WstxOutputFactory.P_AUTOMATIC_EMPTY_ELEMENTS, true); // 1: need output factory SMOutputFactory outf = new SMOutputFactory(factory); try { doc = outf.createOutputDocument(new File(xml_file)); // (optional) 3: enable indentation (note spaces after backslash!) doc.setIndentation("\n\t\t\t\t\t", 1, 1); // 4. comment regarding generation time doc.addComment(" generated by "+Master.AppName+" "+Master.AppVersion+" on " + new java.util.Date().toString()); } catch (XMLStreamException e) { e.printStackTrace(); } } }
Example #2
Source File: BasicSerializableRepository.java From sakai with Educational Community License v2.0 | 5 votes |
private XmlMapper createXMLMapper() { final XMLInputFactory ifactory = new WstxInputFactory(); ifactory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, 32000); ifactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false); final XMLOutputFactory ofactory = new WstxOutputFactory(); ofactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, true); ofactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); final XmlFactory xf = new XmlFactory(ifactory, ofactory); final XmlMapper mapper = new XmlMapper(xf); mapper.registerModules(new JavaTimeModule()); return mapper; }
Example #3
Source File: FormattingXmlStreamWriter.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
public static FormattingXmlStreamWriter create(OutputStream output, OutputFormat format) throws XMLStreamException, FactoryConfigurationError { // always use WoodstoX XMLOutputFactory factory = new WstxOutputFactory(); factory.setProperty(WstxOutputProperties.P_USE_DOUBLE_QUOTES_IN_XML_DECL, true); return new FormattingXmlStreamWriter(factory, output, format); }
Example #4
Source File: BasicSerializableRepository.java From sakai with Educational Community License v2.0 | 5 votes |
private XmlMapper createXMLMapper() { final XMLInputFactory ifactory = new WstxInputFactory(); ifactory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, 32000); ifactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false); final XMLOutputFactory ofactory = new WstxOutputFactory(); ofactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, true); ofactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); final XmlFactory xf = new XmlFactory(ifactory, ofactory); final XmlMapper mapper = new XmlMapper(xf); mapper.registerModules(new JavaTimeModule()); return mapper; }
Example #5
Source File: JacksonXML.java From dropwizard-xml with Apache License 2.0 | 5 votes |
/** * Creates a new {@link com.fasterxml.jackson.dataformat.xml.XmlMapper} using Woodstox * with Logback and Joda Time support. * Also includes all {@link io.dropwizard.jackson.Discoverable} interface implementations. * * @return XmlMapper */ public static XmlMapper newXMLMapper(JacksonXmlModule jacksonXmlModule) { final XmlFactory woodstoxFactory = new XmlFactory(new WstxInputFactory(), new WstxOutputFactory()); final XmlMapper mapper = new XmlMapper(woodstoxFactory, jacksonXmlModule); mapper.registerModule(new GuavaModule()); mapper.registerModule(new GuavaExtrasModule()); mapper.registerModule(new JodaModule()); mapper.registerModule(new FuzzyEnumModule()); mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy()); mapper.setSubtypeResolver(new DiscoverableSubtypeResolver()); return mapper; }
Example #6
Source File: XmlModule.java From proteus with Apache License 2.0 | 4 votes |
@Override protected void configure() { XMLInputFactory inputFactory = new WstxInputFactory(); inputFactory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, 32000); bind(XMLInputFactory.class).toInstance(inputFactory); XMLOutputFactory outputFactory = new WstxOutputFactory(); outputFactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, true); bind(XMLOutputFactory.class).toInstance(outputFactory); XmlFactory xmlFactory = new XmlFactory(inputFactory, outputFactory); XmlMapper xmlMapper = new XmlMapper(xmlFactory); xmlMapper.registerModule(new JavaTimeModule()) .registerModule(new ParameterNamesModule()) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION); bind(XmlMapper.class).toInstance(xmlMapper); }
Example #7
Source File: WstxDriver.java From lams with GNU General Public License v2.0 | 4 votes |
protected XMLOutputFactory createOutputFactory() { return new WstxOutputFactory(); }
Example #8
Source File: OutputFactoryProviderImpl.java From woodstox with Apache License 2.0 | 4 votes |
@Override public XMLOutputFactory2 createOutputFactory() { return new WstxOutputFactory(); }
Example #9
Source File: BaseWstxTest.java From woodstox with Apache License 2.0 | 4 votes |
protected WstxOutputFactory getWstxOutputFactory() { return (WstxOutputFactory) getOutputFactory(); }
Example #10
Source File: BaseWstxTest.java From woodstox with Apache License 2.0 | 4 votes |
protected static XMLOutputFactory2 getNewOutputFactory() { return new WstxOutputFactory(); }
Example #11
Source File: TestOutputFactory.java From woodstox with Apache License 2.0 | 4 votes |
public void testConfig() throws XMLStreamException { XMLOutputFactory2 f = getNewOutputFactory(); WriterConfig cfg = ((WstxOutputFactory) f).getConfig(); assertNotNull(cfg); assertFalse(f.isPropertySupported("foobar")); // Let's just test some of known properties that should be supported... assertTrue(f.isPropertySupported(WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE)); assertTrue(f.isPropertySupported(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT)); // And their default values? assertEquals(Boolean.TRUE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE)); assertEquals(Boolean.TRUE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT)); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_ATTR)); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES)); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT)); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_COPY_DEFAULT_ATTRS)); // As per [WSTX-120], default with Woodstox 4.0 is false: assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_FIX_CONTENT)); assertEquals(Boolean.TRUE, f.getProperty(XMLOutputFactory2.P_AUTOMATIC_EMPTY_ELEMENTS)); assertEquals(Boolean.TRUE, f.getProperty(XMLStreamProperties.XSP_NAMESPACE_AWARE)); assertNull(f.getProperty(XMLStreamProperties.XSP_PROBLEM_REPORTER)); assertNull(f.getProperty(XMLOutputFactory2.P_TEXT_ESCAPER)); assertNull(f.getProperty(XMLOutputFactory2.P_ATTR_VALUE_ESCAPER)); // ... which can be changed f.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE, Boolean.FALSE); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE)); f.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT, Boolean.FALSE); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT)); f.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT, Boolean.FALSE); assertEquals(Boolean.FALSE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT)); f.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES, Boolean.TRUE); assertEquals(Boolean.TRUE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES)); f.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_ATTR, Boolean.TRUE); assertEquals(Boolean.TRUE, f.getProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_ATTR)); }