| 965 | // </rdf:Description> |
| 966 | |
| 967 | static void |
| 968 | SerializeCompactRDFSchemas ( const XMP_Node & xmpTree, |
| 969 | XMP_VarString & outputStr, |
| 970 | XMP_StringPtr newline, |
| 971 | XMP_StringPtr indentStr, |
| 972 | XMP_Index baseIndent ) |
| 973 | { |
| 974 | XMP_Index level; |
| 975 | size_t schema, schemaLim; |
| 976 | |
| 977 | // Begin the rdf:Description start tag. |
| 978 | for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr; |
| 979 | outputStr += kRDF_SchemaStart; |
| 980 | outputStr += '"'; |
| 981 | outputStr += xmpTree.name; |
| 982 | outputStr += '"'; |
| 983 | |
| 984 | // Write all necessary xmlns attributes. |
| 985 | |
| 986 | size_t totalLen = 8; // Start at 8 for "xml:rdf:". |
| 987 | XMP_cStringMapPos currPos = sNamespacePrefixToURIMap->begin(); |
| 988 | XMP_cStringMapPos endPos = sNamespacePrefixToURIMap->end(); |
| 989 | for ( ; currPos != endPos; ++currPos ) totalLen += currPos->first.size(); |
| 990 | |
| 991 | XMP_VarString usedNS; |
| 992 | usedNS.reserve ( totalLen ); |
| 993 | usedNS = "xml:rdf:"; |
| 994 | |
| 995 | for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) { |
| 996 | const XMP_Node * currSchema = xmpTree.children[schema]; |
| 997 | DeclareUsedNamespaces ( currSchema, usedNS, outputStr, newline, indentStr, baseIndent+4 ); |
| 998 | } |
| 999 | |
| 1000 | // Write the top level "attrProps" and close the rdf:Description start tag. |
| 1001 | bool allAreAttrs = true; |
| 1002 | for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) { |
| 1003 | const XMP_Node * currSchema = xmpTree.children[schema]; |
| 1004 | allAreAttrs &= SerializeCompactRDFAttrProps ( currSchema, outputStr, newline, indentStr, baseIndent+3 ); |
| 1005 | } |
| 1006 | if ( ! allAreAttrs ) { |
| 1007 | outputStr += ">"; |
| 1008 | outputStr += newline; |
| 1009 | } else { |
| 1010 | outputStr += "/>"; |
| 1011 | outputStr += newline; |
| 1012 | return; // ! Done if all properties in all schema are written as attributes. |
| 1013 | } |
| 1014 | |
| 1015 | // Write the remaining properties for each schema. |
| 1016 | for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) { |
| 1017 | const XMP_Node * currSchema = xmpTree.children[schema]; |
| 1018 | SerializeCompactRDFElemProps ( currSchema, outputStr, newline, indentStr, baseIndent+3 ); |
| 1019 | } |
| 1020 | |
| 1021 | // Write the rdf:Description end tag. |
| 1022 | // *** Elide the end tag if everything (all props in all schema) is an attr. |
| 1023 | for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr; |
| 1024 | outputStr += kRDF_SchemaEnd; |
no test coverage detected