public void serialize()

in src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java [225:263]


    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
        String namespace = Constants.findPolicyNamespace(writer);
        String pfx = writer.getPrefix(name.getNamespaceURI());
        boolean writeNS = false;
        if (pfx == null && name.getPrefix() != null && !"".equals(name.getPrefix())) {
            pfx = name.getPrefix();
            writeNS = true;
        }
        if ("".equals(pfx) || pfx == null) {
            pfx = "";
            writeNS = true;
        }
        
        if (!hasContents() && attributes == null && !writeNS) {
            writer.writeEmptyElement(pfx, name.getLocalPart(), name.getNamespaceURI());
            return;
        }
        
        writer.writeStartElement(pfx, name.getLocalPart(), name.getNamespaceURI());
        
        if (writeNS) {
            if ("".equals(pfx) || pfx == null) {
                writer.writeDefaultNamespace(name.getNamespaceURI());
            } else if (attributes == null 
                || !attributes.containsKey(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, pfx))) {
                writer.writeNamespace(pfx, name.getNamespaceURI());
            }
        }
        
        if (optional) {
            writer.writeAttribute(namespace, Constants.ATTR_OPTIONAL, "true");
        }
        if (ignorable) {
            writer.writeAttribute(namespace, Constants.ATTR_IGNORABLE, "true");
        }
        writeAttributes(writer);
        writeContents(writer);
        writer.writeEndElement();
    }