@Override public void persist(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { boolean wildcard = getPathElement().isWildcard(); model = wildcard ? model.get(getPathElement().getKey()) : model.get(getPathElement().getKeyValuePair()); if (!model.isDefined()) { return; } boolean writeWrapper = getXmlWrapperElement() != null; if (writeWrapper) { writer.writeStartElement(getXmlWrapperElement()); } writer.writeStartElement(getXmlElementName()); if (wildcard) { for (Property p : model.asPropertyList()) { writer.writeAttribute(NAME, p.getName()); for (AttributeDefinition def : getAttributes()) { def.getAttributeMarshaller().marshallAsAttribute(def, p.getValue(), false, writer); } persistChildren(writer, p.getValue()); } } else { for (AttributeDefinition def : getAttributes()) { def.getAttributeMarshaller().marshallAsAttribute(def, model, false, writer); } persistChildren(writer, model); } writer.writeEndElement(); if (writeWrapper) { writer.writeEndElement(); } }
public void persist(XMLExtendedStreamWriter writer, ModelNode model, String namespaceURI) throws XMLStreamException { boolean wildcard = getPathElement().isWildcard(); model = wildcard ? model.get(getPathElement().getKey()) : model.get(getPathElement().getKeyValuePair()); if (!model.isDefined() && !useValueAsElementName()) { return; } boolean isSubsystem = getPathElement().getKey().equals(ModelDescriptionConstants.SUBSYSTEM); boolean writeWrapper = getXmlWrapperElement() != null; if (writeWrapper) { writeStartElement(writer, namespaceURI, getXmlWrapperElement()); } if (wildcard) { for (Property p : model.asPropertyList()) { if (useValueAsElementName()) { writeStartElement(writer, namespaceURI, p.getName()); } else { writeStartElement(writer, namespaceURI, getXmlElementName()); writer.writeAttribute(NAME, p.getName()); } for (AttributeDefinition def : getAttributes()) { def.getAttributeMarshaller().marshallAsAttribute(def, p.getValue(), false, writer); } persistChildren(writer, p.getValue()); writer.writeEndElement(); } } else { if (useValueAsElementName()) { writeStartElement(writer, namespaceURI, getPathElement().getValue()); } else if (isSubsystem) { startSubsystemElement(writer, namespaceURI, getChildren().isEmpty()); } else { writeStartElement(writer, namespaceURI, getXmlElementName()); } for (AttributeDefinition def : getAttributes()) { def.getAttributeMarshaller().marshallAsAttribute(def, model, false, writer); } persistChildren(writer, model); writer.writeEndElement(); } if (writeWrapper) { writer.writeEndElement(); } }