// ! The value is output by a recursive call ON THE SAME NODE with
// emitAsRDFValue set.
if (hasRDFResourceQual)
{
throw new XMPException("Can't mix rdf:resource and general qualifiers",
XMPError.BADRDF);
}
// Change serialization to canonical format with inner rdf:Description-tag
// depending on option
if (useCanonicalRDF)
{
write(">");
writeNewline();
indent++;
writeIndent(indent);
write(RDF_STRUCT_START);
write(">");
}
else
{
write(" rdf:parseType=\"Resource\">");
}
writeNewline();
serializeCanonicalRDFProperty(node, useCanonicalRDF, true, indent + 1);
for (Iterator it = node.iterateQualifier(); it.hasNext();)
{
XMPNode qualifier = (XMPNode) it.next();
if (!RDF_ATTR_QUALIFIER.contains(qualifier.getName()))
{
serializeCanonicalRDFProperty(qualifier, useCanonicalRDF, false, indent + 1);
}
}
if (useCanonicalRDF)
{
writeIndent(indent);
write(RDF_STRUCT_END);
writeNewline();
indent--;
}
}
else
{
// This node has no general qualifiers. Emit using an unqualified form.
if (!node.getOptions().isCompositeProperty())
{
// This is a simple property.
if (node.getOptions().isURI())
{
write(" rdf:resource=\"");
appendNodeValue(node.getValue(), true);
write("\"/>");
writeNewline();
emitEndTag = false;
}
else if (node.getValue() == null || "".equals(node.getValue()))
{
write("/>");
writeNewline();
emitEndTag = false;
}
else
{
write('>');
appendNodeValue(node.getValue(), false);
indentEndTag = false;
}
}
else if (node.getOptions().isArray())
{
// This is an array.
write('>');
writeNewline();
emitRDFArrayTag(node, true, indent + 1);
if (node.getOptions().isArrayAltText())
{
XMPNodeUtils.normalizeLangArray(node);
}
for (Iterator it = node.iterateChildren(); it.hasNext();)
{
XMPNode child = (XMPNode) it.next();
serializeCanonicalRDFProperty(child, useCanonicalRDF, false, indent + 2);
}
emitRDFArrayTag(node, false, indent + 1);
}
else if (!hasRDFResourceQual)
{
// This is a "normal" struct, use the rdf:parseType="Resource" form.
if (!node.hasChildren())
{
// Change serialization to canonical format with inner rdf:Description-tag
// if option is set
if (useCanonicalRDF)
{
write(">");
writeNewline();
writeIndent(indent + 1);
write(RDF_EMPTY_STRUCT);
}
else
{
write(" rdf:parseType=\"Resource\"/>");
emitEndTag = false;
}
writeNewline();
}
else
{
// Change serialization to canonical format with inner rdf:Description-tag
// if option is set
if (useCanonicalRDF)
{
write(">");
writeNewline();
indent++;
writeIndent(indent);
write(RDF_STRUCT_START);
write(">");
}
else
{
write(" rdf:parseType=\"Resource\">");
}
writeNewline();
for (Iterator it = node.iterateChildren(); it.hasNext();)
{
XMPNode child = (XMPNode) it.next();
serializeCanonicalRDFProperty(child, useCanonicalRDF, false, indent + 1);
}
if (useCanonicalRDF)
{
writeIndent(indent);
write(RDF_STRUCT_END);
writeNewline();
indent--;
}
}
}
else
{
// This is a struct with an rdf:resource attribute, use the
// "empty property element" form.
for (Iterator it = node.iterateChildren(); it.hasNext();)
{
XMPNode child = (XMPNode) it.next();
if (!canBeRDFAttrProp(child))
{
throw new XMPException("Can't mix rdf:resource and complex fields",
XMPError.BADRDF);
}
writeNewline();
writeIndent(indent + 1);
write(' ');