}
// if we are a reference to a type we should lookup the original
// as this ElementDescriptor will be 'hollow' and have no child attributes/elements.
// XXX: this should probably be done by the NodeDescriptors...
ElementDescriptor typeDescriptor = getElementDescriptor( currentDescriptor );
//ElementDescriptor typeDescriptor = descriptor;
ElementDescriptor[] childDescriptors = typeDescriptor.getElementDescriptors();
if ( childDescriptors != null ) {
for ( int i = 0, size = childDescriptors.length; i < size; i++ ) {
final ElementDescriptor childDescriptor = childDescriptors[i];
if (log.isTraceEnabled()) {
log.trace("Processing child " + childDescriptor);
}
String qualifiedName = childDescriptor.getQualifiedName();
if ( qualifiedName == null ) {
log.trace( "Ignoring" );
continue;
}
String path = prefix + qualifiedName;
// this code is for making sure that recursive elements
// can also be used..
if ( qualifiedName.equals( currentDescriptor.getQualifiedName() )
&& currentDescriptor.getPropertyName() != null ) {
log.trace("Creating generic rule for recursive elements");
int index = -1;
if (childDescriptor.isWrapCollectionsInElement()) {
index = prefix.indexOf(qualifiedName);
if (index == -1) {
// shouldn't happen..
log.debug( "Oops - this shouldn't happen" );
continue;
}
int removeSlash = prefix.endsWith("/")?1:0;
path = "*/" + prefix.substring(index, prefix.length()-removeSlash);
if (log.isTraceEnabled()) {
log.trace("Added wrapped rule for " + childDescriptor);
}
} else {
// we have a element/element type of thing..
ElementDescriptor[] desc = currentDescriptor.getElementDescriptors();
if (desc.length == 1) {
path = "*/"+desc[0].getQualifiedName();
}
if (log.isTraceEnabled()) {
log.trace("Added not wrapped rule for " + childDescriptor);
}
}
addRule( path, childDescriptor, context );
continue;
}
if ( childDescriptor.getUpdater() != null ) {
if (
log.isTraceEnabled()
&& childDescriptor.getUpdater() instanceof MethodUpdater) {
log.trace("Element has updater "
+ ((MethodUpdater) childDescriptor.getUpdater()).getMethod().getName());
}
if ( childDescriptor.isPrimitiveType() ) {
addPrimitiveTypeRule( path, childDescriptor, context );
} else {
// add the first child to the path
ElementDescriptor[] grandChildren
= childDescriptor.getElementDescriptors();
if ( grandChildren != null && grandChildren.length > 0 ) {
ElementDescriptor grandChild = grandChildren[0];
String grandChildQName = grandChild.getQualifiedName();
if ( grandChildQName != null && grandChildQName.length() > 0 ) {
if (childDescriptor.isWrapCollectionsInElement()) {
path += '/' + grandChildQName;
if (log.isTraceEnabled()) {
log.trace(