use of ezvcard.property.Xml in project ez-vcard by mangstadt.
the class XmlScribe method _parseXml.
@Override
protected Xml _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) {
Xml xml = new Xml(element.element());
// remove the <parameters> element
Element root = xml.getValue().getDocumentElement();
for (Element child : XmlUtils.toElementList(root.getChildNodes())) {
if ("parameters".equals(child.getLocalName()) && VCardVersion.V4_0.getXmlNamespace().equals(child.getNamespaceURI())) {
root.removeChild(child);
}
}
return xml;
}
use of ezvcard.property.Xml in project ez-vcard by mangstadt.
the class XCardWriter method write.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void write(VCardProperty property, VCard vcard) throws SAXException {
VCardPropertyScribe scribe = index.getPropertyScribe(property);
VCardParameters parameters = scribe.prepareParameters(property, targetVersion, vcard);
// get the property element to write
Element propertyElement;
if (property instanceof Xml) {
Xml xml = (Xml) property;
Document value = xml.getValue();
if (value == null) {
return;
}
propertyElement = value.getDocumentElement();
} else {
QName qname = scribe.getQName();
propertyElement = DOC.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
try {
scribe.writeXml(property, propertyElement);
} catch (SkipMeException e) {
return;
} catch (EmbeddedVCardException e) {
return;
}
}
start(propertyElement);
write(parameters);
write(propertyElement);
end(propertyElement);
}
Aggregations