private void initialize() { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); transformer = xmlPlatform.newXMLTransformer(); setEncoding(XMLConstants.DEFAULT_XML_ENCODING); setFormattedOutput(true); marshalProperties = new Properties(); }
public void setProperty(String propName, Object value) throws PropertyException { if (null == propName) { throw new IllegalArgumentException(propName); } String valueString = (value == null) ? null : value.toString(); if (propName.equals(Marshaller.JAXB_ENCODING)) { this.xmlBinder.getMarshaller().setEncoding(valueString); return; } if (propName.equals(Marshaller.JAXB_FORMATTED_OUTPUT)) { this.xmlBinder.getMarshaller().setFormattedOutput(Boolean.valueOf(valueString).booleanValue()); return; } if (propName.equals(Marshaller.JAXB_FRAGMENT)) { this.xmlBinder.getMarshaller().setFragment(Boolean.valueOf(valueString).booleanValue()); return; } if (propName.equals(Marshaller.JAXB_SCHEMA_LOCATION)) { this.xmlBinder.getMarshaller().setSchemaLocation(valueString); return; } if (propName.equals(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION)) { this.xmlBinder.getMarshaller().setNoNamespaceSchemaLocation(valueString); return; } throw new PropertyException(propName); }
@Override public void setProperty(String propName, Object value) throws PropertyException { if (null == propName) { throw new IllegalArgumentException((String)null); } String valueString = (value == null) ? null : value.toString(); if (propName.equals(Marshaller.JAXB_ENCODING)) { this.xmlBinder.getMarshaller().setEncoding(valueString); return; } if (propName.equals(Marshaller.JAXB_FORMATTED_OUTPUT)) { this.xmlBinder.getMarshaller().setFormattedOutput(Boolean.valueOf(valueString).booleanValue()); return; } if (propName.equals(Marshaller.JAXB_FRAGMENT)) { this.xmlBinder.getMarshaller().setFragment(Boolean.valueOf(valueString).booleanValue()); return; } if (propName.equals(Marshaller.JAXB_SCHEMA_LOCATION)) { this.xmlBinder.getMarshaller().setSchemaLocation(valueString); return; } if (propName.equals(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION)) { this.xmlBinder.getMarshaller().setNoNamespaceSchemaLocation(valueString); return; } throw new PropertyException(propName); }
/** * This constructor initializes various settings on the XML marshaller. * * @param newXMLMarshaller xml marshaller * @param jaxbContext jaxb context */ public JAXBMarshaller(XMLMarshaller newXMLMarshaller, JAXBContext jaxbContext) { this.jaxbContext = jaxbContext; validationEventHandler = JAXBContext.DEFAULT_VALIDATION_EVENT_HANDLER; beanValidationMode = BeanValidationMode.AUTO; beanValidator = JAXBBeanValidator.getMarshallingBeanValidator(jaxbContext); xmlMarshaller = newXMLMarshaller; xmlMarshaller.setErrorHandler(new JAXBErrorHandler(validationEventHandler)); xmlMarshaller.setEncoding("UTF-8"); xmlMarshaller.setFormattedOutput(false); xmlMarshaller.getProperties().put(Constants.JAXB_MARSHALLER, this); }
/** * This constructor initializes various settings on the XML marshaller. * * @param newXMLMarshaller xml marshaller * @param jaxbContext jaxb context */ public JAXBMarshaller(XMLMarshaller newXMLMarshaller, JAXBContext jaxbContext) { this.jaxbContext = jaxbContext; validationEventHandler = JAXBContext.DEFAULT_VALIDATION_EVENT_HANDLER; beanValidationMode = BeanValidationMode.AUTO; if (BeanValidationChecker.isBeanValidationPresent()) { beanValidator = JAXBBeanValidator.getMarshallingBeanValidator(jaxbContext); } xmlMarshaller = newXMLMarshaller; xmlMarshaller.setErrorHandler(new JAXBErrorHandler(validationEventHandler)); xmlMarshaller.setEncoding("UTF-8"); xmlMarshaller.setFormattedOutput(false); xmlMarshaller.getProperties().put(Constants.JAXB_MARSHALLER, this); }
xmlMarshaller.setFormattedOutput(formattedOutput.booleanValue()); } else if (JAXB_ENCODING.equals(key)) { xmlMarshaller.setEncoding((String) value); } else if (JAXB_SCHEMA_LOCATION.equals(key)) { xmlMarshaller.setSchemaLocation((String) value);
xmlMarshaller.setFormattedOutput(formattedOutput.booleanValue()); } else if (JAXB_ENCODING.equals(key)) { xmlMarshaller.setEncoding((String) value); } else if (JAXB_SCHEMA_LOCATION.equals(key)) { xmlMarshaller.setSchemaLocation((String) value);
anXMLMarshaller.setEncoding(xmlDocument.getEncoding()); anXMLMarshaller.setSchemaLocation(xmlDocument.getSchemaLocation()); anXMLMarshaller.setNoNamespaceSchemaLocation(xmlDocument.getNoNamespaceSchemaLocation());
anXMLMarshaller.setEncoding(xmlDocument.getEncoding()); anXMLMarshaller.setSchemaLocation(xmlDocument.getSchemaLocation()); anXMLMarshaller.setNoNamespaceSchemaLocation(xmlDocument.getNoNamespaceSchemaLocation());
anXMLMarshaller.setEncoding(xmlDocument.getEncoding()); anXMLMarshaller.setSchemaLocation(xmlDocument.getSchemaLocation()); anXMLMarshaller.setNoNamespaceSchemaLocation(xmlDocument.getNoNamespaceSchemaLocation());
anXMLMarshaller.setEncoding(xmlDocument.getEncoding()); anXMLMarshaller.setSchemaLocation(xmlDocument.getSchemaLocation()); anXMLMarshaller.setNoNamespaceSchemaLocation(xmlDocument.getNoNamespaceSchemaLocation());