}
// try referring to content model for information on
// whitespace & indent strategy
ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) currentNode.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(currentNode);
if (elementDeclaration != null) {
// follow whitespace strategy preference for
// pcdata content
int contentType = elementDeclaration.getContentType();
String facetValue = null;
if(elementDeclaration.getDataType() != null)
facetValue = (String) elementDeclaration.getDataType().getProperty(PROPERTY_WHITESPACE_FACET);
if(facetValue != null) {
if(PRESERVE.equals(facetValue))
childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
// For XSD types, "collapse" corresponds to the IGNOREANDTRIM strategy
else if(COLLAPSE.equals(facetValue))
childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNOREANDTRIM);
else if(REPLACE.equals(facetValue))
childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.REPLACE);
}
else if (contentType == CMElementDeclaration.PCDATA && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
childConstraints.setWhitespaceStrategy(preferences.getPCDataWhitespaceStrategy());
}
else if (contentType == CMElementDeclaration.ELEMENT && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNORE);
childConstraints.setIndentStrategy(XMLFormattingConstraints.INDENT);
childConstraints.setIsWhitespaceStrategyAHint(true);
childConstraints.setIsIndentStrategyAHint(true);
}
else {
// look for xml:space in content model
CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes();
// Not needed - we're looking for xml:space
//CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmAttributes);
//List nodes = ModelQueryUtil.getModelQuery(currentNode.getOwnerDocument()).getAvailableContent((Element) currentNode, elementDeclaration, ModelQuery.INCLUDE_ATTRIBUTES);
//for (int k = 0; k < nodes.size(); k++) {