Package org.apache.xmpbox.xml
Class XmpSerializer
- java.lang.Object
-
- org.apache.xmpbox.xml.XmpSerializer
-
public class XmpSerializer extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private javax.xml.parsers.DocumentBuilder
documentBuilder
private boolean
parseTypeResourceForLi
private javax.xml.transform.TransformerFactory
transformerFactory
-
Constructor Summary
Constructors Constructor Description XmpSerializer()
Default constructor.XmpSerializer(javax.xml.transform.TransformerFactory transformerFactory, javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
Constructor to be used if other factories than the default ones are needed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.w3c.dom.Element
createRdfElement(org.w3c.dom.Document doc, XMPMetadata metadata, boolean withXpacket)
private void
fillElementWithAttributes(org.w3c.dom.Element target, AbstractComplexProperty property)
private java.util.List<Attribute>
normalizeAttributes(AbstractComplexProperty property)
Normalize the list of attributes.private void
save(org.w3c.dom.Node doc, java.io.OutputStream outStream, java.lang.String encoding)
Save the XML document to an output stream.void
serialize(XMPMetadata metadata, java.io.OutputStream os, boolean withXpacket)
void
serializeFields(org.w3c.dom.Document doc, org.w3c.dom.Element parent, java.util.List<AbstractField> fields, java.lang.String resourceNS, java.lang.String prefix, boolean wrapWithProperty)
protected org.w3c.dom.Element
serializeSchema(org.w3c.dom.Document doc, XMPSchema schema)
-
-
-
Constructor Detail
-
XmpSerializer
public XmpSerializer()
Default constructor.
-
XmpSerializer
public XmpSerializer(javax.xml.transform.TransformerFactory transformerFactory, javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
Constructor to be used if other factories than the default ones are needed.- Parameters:
transformerFactory
- transformer factory to be useddocumentBuilderFactory
- document builder factory to be used
-
-
Method Detail
-
serialize
public void serialize(XMPMetadata metadata, java.io.OutputStream os, boolean withXpacket) throws javax.xml.transform.TransformerException
- Throws:
javax.xml.transform.TransformerException
-
serializeSchema
protected org.w3c.dom.Element serializeSchema(org.w3c.dom.Document doc, XMPSchema schema)
-
serializeFields
public void serializeFields(org.w3c.dom.Document doc, org.w3c.dom.Element parent, java.util.List<AbstractField> fields, java.lang.String resourceNS, java.lang.String prefix, boolean wrapWithProperty)
-
fillElementWithAttributes
private void fillElementWithAttributes(org.w3c.dom.Element target, AbstractComplexProperty property)
-
normalizeAttributes
private java.util.List<Attribute> normalizeAttributes(AbstractComplexProperty property)
Normalize the list of attributes. Attributes which match a schema property are serialized as child elements so only return the ones which do not match a schema property- Parameters:
property
- the property that needs to be inspected- Returns:
- the list of attributed for serializing
-
createRdfElement
protected org.w3c.dom.Element createRdfElement(org.w3c.dom.Document doc, XMPMetadata metadata, boolean withXpacket)
-
save
private void save(org.w3c.dom.Node doc, java.io.OutputStream outStream, java.lang.String encoding) throws javax.xml.transform.TransformerException
Save the XML document to an output stream.- Parameters:
doc
- The XML document to save.outStream
- The stream to save the document to.encoding
- The encoding to save the file as.- Throws:
javax.xml.transform.TransformerException
- If there is an error while saving the XML.
-
-