private void processMetadataForChildren()

in modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.java [3797:5176]


    private void processMetadataForChildren(Node parent)
    {
        // Go deep and process excludes..
        NodeList listOfChilds = parent.getChildNodes();
        if (listOfChilds != null && listOfChilds.getLength() != 0)
        {
            for (int ix = 0; ix < listOfChilds.getLength(); ix++)
            {
                Node childNode = listOfChilds.item(ix);
                if (childNode.getNodeType() != Node.ELEMENT_NODE)
                {
                    continue;
                }
                Element child = (Element)childNode;

                processMetadataForChildren(child);
            }
        }

        if (parent.getNodeName().equals("metadata"))
        {
            Element styleElement = asDocUtil.getElementByTagName((Element)parent, "Style");
            if (styleElement != null)
            {
                // skip metadata if private
                NodeList childrenOfStyle = styleElement.getElementsByTagName("private");
                if ((childrenOfStyle != null && childrenOfStyle.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                Element newStyleElement = asDocUtil.renameElementAndImportChild(styleElement, outputObject, "style");

                String name = newStyleElement.getAttribute("name");
                String fullName = newStyleElement.getAttribute("owner");

                AsClass myClass = classTable.get(fullName);

                if (myClass == null)
                {
                    if (verbose)
                    {
                        System.out.println("   Can not resolve style class name: " + fullName);
                    }

                    return;
                }

                Element node = myClass.getNode();

                // we need to get to the Exclude Node. it should be under
                // prolog.asMetadata
                Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                if (prolog != null)
                {
                    Element asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                    if (asMetadata != null)
                    {
                        HashMap<String, String> attributes = new HashMap<String, String>();
                        attributes.put("kind", "style");
                        attributes.put("name", name);
                        
                        Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                        if (excludeElement != null)
                        {
                            if (verbose)
                            {
                                System.out.println("Excluding style " + name + " from " + myClass.getName());
                            }
                            return;
                        }
                    }
                }

                asDocUtil.processCustoms(newStyleElement, outputObject);

                childrenOfStyle = newStyleElement.getElementsByTagName("default");
                if (childrenOfStyle != null && childrenOfStyle.getLength() != 0)
                {
                    Element defaultElement = (Element)childrenOfStyle.item(0);
                    String defaultText = defaultElement.getTextContent();

                    Element newDefaultElement = outputObject.createElement("default");
                    newDefaultElement.setTextContent(defaultText);

                    newStyleElement.replaceChild(newDefaultElement, defaultElement);
                }

                NodeList descriptionList = newStyleElement.getElementsByTagName("description");
                if (descriptionList != null && descriptionList.getLength() != 0)
                {
                    Element descriptionElement = (Element)descriptionList.item(0);
                    String descriptionText = descriptionElement.getTextContent();

                    Element newDescriptionElement = outputObject.createElement("description");
                    CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                    newDescriptionElement.appendChild(cdata);

                    newStyleElement.replaceChild(newDescriptionElement, descriptionElement);
                    asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                }

                childrenOfStyle = newStyleElement.getElementsByTagName("see");
                if (childrenOfStyle != null && childrenOfStyle.getLength() != 0)
                {
                    Element relatedLinks = outputObject.createElement("related-links");
                    for (int ix = 0; ix < childrenOfStyle.getLength(); ix++)
                    {
                        Element seeElement = (Element)childrenOfStyle.item(ix);
                        relatedLinks.appendChild(processSeeTag(fullName, seeElement.getTextContent()));
                    }
                    newStyleElement.appendChild(relatedLinks);

                    for (int ix = 0; ix < childrenOfStyle.getLength(); ix++)
                    {
                        newStyleElement.removeChild(childrenOfStyle.item(ix));
                    }

                }

                childrenOfStyle = newStyleElement.getElementsByTagName("copy");
                if (childrenOfStyle != null && childrenOfStyle.getLength() != 0)
                {
                    String text = childrenOfStyle.item(0).getTextContent();
                    text = text.replaceAll("\\s+", "");

                    descriptionList = newStyleElement.getElementsByTagName("description");
                    Element descriptionElement = null;
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        descriptionElement = (Element)descriptionList.item(0);
                    }
                    else
                    {
                        descriptionElement = outputObject.createElement("description");
                        newStyleElement.appendChild(descriptionElement);
                    }
                    descriptionElement.setAttribute("conref", text);

                    newStyleElement.removeChild(childrenOfStyle.item(0));
                }

                childrenOfStyle = newStyleElement.getElementsByTagName("playerversion");
                if (childrenOfStyle != null && childrenOfStyle.getLength() != 0)
                {
                    String playerversion = childrenOfStyle.item(0).getTextContent();
                    playerversion = playerversion.replaceAll("\\s+", "");

                    newStyleElement.setAttribute("playerVersion", playerversion);
                    newStyleElement.removeChild(childrenOfStyle.item(0));
                }

                Element stylesElement = null;
                Element asMetadata = null;

                if (prolog != null)
                {
                    asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                    if (asMetadata != null)
                    {
                        stylesElement = asDocUtil.getElementByTagName(asMetadata, "styles");

                        if (stylesElement == null)
                        {
                            stylesElement = outputObject.createElement("styles");
                            asMetadata.appendChild(stylesElement);
                        }
                    }
                    else
                    {
                        stylesElement = outputObject.createElement("styles");
                        asMetadata = outputObject.createElement("asMetadata");

                        asMetadata.appendChild(stylesElement);
                        prolog.appendChild(asMetadata);

                    }
                }
                else
                {
                    stylesElement = outputObject.createElement("styles");
                    asMetadata = outputObject.createElement("asMetadata");
                    asMetadata.appendChild(stylesElement);
                    prolog = outputObject.createElement("prolog");
                    prolog.appendChild(asMetadata);
                    myClass.getNode().appendChild(prolog);
                }

                newStyleElement = (Element)outputObject.importNode(newStyleElement, true);
                stylesElement.appendChild(newStyleElement);
            }

            Element effectElement = asDocUtil.getElementByTagName((Element)parent, "Effect");
            if (effectElement != null)
            {
                // skip metadata if private
                NodeList childrenOfEffect = effectElement.getElementsByTagName("private");
                if ((childrenOfEffect != null && childrenOfEffect.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                Element newEffectElement = asDocUtil.renameElementAndImportChild(effectElement, outputObject, "effect");

                String name = newEffectElement.getAttribute("name");
                String fullName = newEffectElement.getAttribute("owner");

                AsClass myClass = classTable.get(fullName);

                if (myClass == null)
                {
                    if (verbose)
                    {
                        System.out.println("   Can not resolve effect class name: " + fullName);
                    }
                    return;
                }

                Element node = myClass.getNode();

                // we need to get to the Exclude Node. it should be under
                // prolog.asMetadata
                Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                if (prolog != null)
                {
                    Element asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                    if (asMetadata != null)
                    {
                        HashMap<String, String> attributes = new HashMap<String, String>();
                        attributes.put("kind", "effect");
                        attributes.put("name", name);
                        
                        Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                        if (excludeElement != null)
                        {
                            if (verbose)
                            {
                                System.out.println("Excluding effect " + name + " from " + myClass.getName());
                            }
                            return;
                        }
                    }
                }

                asDocUtil.processCustoms(newEffectElement, outputObject);

                childrenOfEffect = newEffectElement.getElementsByTagName("default");
                if (childrenOfEffect != null && childrenOfEffect.getLength() != 0)
                {
                    Element defaultElement = (Element)childrenOfEffect.item(0);
                    String defaultText = defaultElement.getTextContent();

                    Element newDefaultElement = outputObject.createElement("default");
                    newDefaultElement.setTextContent(defaultText);

                    newEffectElement.replaceChild(newDefaultElement, defaultElement);
                }

                NodeList descriptionList = newEffectElement.getElementsByTagName("description");
                if (descriptionList != null && descriptionList.getLength() != 0)
                {
                    Element descriptionElement = (Element)descriptionList.item(0);
                    String descriptionText = descriptionElement.getTextContent();

                    Element newDescriptionElement = outputObject.createElement("description");
                    CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                    newDescriptionElement.appendChild(cdata);

                    newEffectElement.replaceChild(newDescriptionElement, descriptionElement);
                    asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                }

                childrenOfEffect = newEffectElement.getElementsByTagName("copy");
                if (childrenOfEffect != null && childrenOfEffect.getLength() != 0)
                {
                    String text = childrenOfEffect.item(0).getTextContent();
                    text = text.replaceAll("[\\n\\s]", "");

                    descriptionList = newEffectElement.getElementsByTagName("description");
                    Element descriptionElement = null;
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        descriptionElement = (Element)descriptionList.item(0);
                    }
                    else
                    {
                        descriptionElement = outputObject.createElement("description");
                        newEffectElement.appendChild(descriptionElement);
                    }
                    descriptionElement.setAttribute("conref", text);

                    newEffectElement.removeChild(childrenOfEffect.item(0));
                }

                Element effectsElement = null;
                Element asMetadata = null;

                if (prolog != null)
                {
                    asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                    if (asMetadata != null)
                    {
                        effectsElement = asDocUtil.getElementByTagName(asMetadata, "effects");

                        if (effectsElement == null)
                        {
                            effectsElement = outputObject.createElement("effects");
                            asMetadata.appendChild(effectsElement);
                        }
                    }
                    else
                    {
                        effectsElement = outputObject.createElement("effects");
                        asMetadata = outputObject.createElement("asMetadata");

                        asMetadata.appendChild(effectsElement);
                        prolog.appendChild(asMetadata);

                    }
                }
                else
                {
                    effectsElement = outputObject.createElement("effects");
                    asMetadata = outputObject.createElement("asMetadata");
                    asMetadata.appendChild(effectsElement);
                    prolog = outputObject.createElement("prolog");
                    prolog.appendChild(asMetadata);
                    myClass.getNode().appendChild(prolog);
                }

                newEffectElement = (Element)outputObject.importNode(newEffectElement, true);
                effectsElement.appendChild(newEffectElement);
            }

            Element eventElement = asDocUtil.getElementByTagName((Element)parent, "Event");
            if (eventElement != null)
            {
                // skip metadata if private
                NodeList childrenOfEvent = eventElement.getElementsByTagName("private");
                if ((childrenOfEvent != null && childrenOfEvent.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                String name = eventElement.getAttribute("name");
                String fullName = eventElement.getAttribute("owner");

                AsClass myClass = classTable.get(fullName);

                if (myClass == null)
                {
                    if (verbose)
                    {
                        System.out.println("   Can not resolve event  class name: " + fullName);
                    }
                    return;
                }

                Element node = myClass.getNode();

                // we need to get to the Exclude Node. it should be under
                // prolog.asMetadata
                Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                if (prolog != null)
                {
                    Element asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                    if (asMetadata != null)
                    {
                        HashMap<String, String> attributes = new HashMap<String, String>();
                        attributes.put("kind", "event");
                        attributes.put("name", name);
                        
                        Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                        if (excludeElement != null)
                        {
                            if (verbose)
                            {
                                System.out.println("Excluding event " + name + " from " + myClass.getName());
                            }
                            return;
                        }
                    }
                }

                String eventType = null;
                childrenOfEvent = ((Element)parent).getElementsByTagName("eventType");
                if (childrenOfEvent != null && childrenOfEvent.getLength() != 0)
                {
                    eventType = childrenOfEvent.item(0).getTextContent().replaceAll("\\s+", "");
                }

                String eventObjectType = eventElement.getAttribute("type");
                String fullDesc = "";

                childrenOfEvent = eventElement.getElementsByTagName("description");
                if (childrenOfEvent != null && childrenOfEvent.getLength() != 0)
                {
                    Element descriptionElement = (Element)childrenOfEvent.item(0);
                    descriptionElement.normalize();

                    fullDesc = descriptionElement.getTextContent();
                }

                String eventId = null;

                if (eventType != null)
                {
                    eventId = asDocUtil.formatId(myClass.getFullName()) + "_" + asDocUtil.formatId(eventType) + "_" + name;
                }
                else
                {
                    eventId = asDocUtil.formatId(myClass.getFullName()) + "_" + asDocUtil.formatId(eventObjectType) + "_" + name;
                }

                Element adobeApiEvent = outputObject.createElement("adobeApiEvent");
                adobeApiEvent.setAttribute("id", eventId);
                Element apiName = outputObject.createElement("apiName");
                apiName.setTextContent(name);
                adobeApiEvent.appendChild(apiName);

                Element shortdesc = outputObject.createElement("shortdesc");
                adobeApiEvent.appendChild(shortdesc);
                adobeApiEvent.appendChild(outputObject.createElement("prolog"));
                Element adobeApiEventDetail = outputObject.createElement("adobeApiEventDetail");
                adobeApiEvent.appendChild(adobeApiEventDetail);

                Element adobeApiEventDef = outputObject.createElement("adobeApiEventDef");
                adobeApiEventDetail.appendChild(adobeApiEventDef);

                if (eventType != null)
                {
                    Element apiEventType = outputObject.createElement("apiEventType");
                    apiEventType.setTextContent(eventType);
                    adobeApiEventDef.appendChild(apiEventType);
                }

                if (eventObjectType != null)
                {
                    Element adobeApiEventClassifier = outputObject.createElement("adobeApiEventClassifier");
                    adobeApiEventClassifier.setTextContent(eventObjectType);
                    adobeApiEventDef.appendChild(adobeApiEventClassifier);
                }

                Element apiGeneratedEvent = outputObject.createElement("apiGeneratedEvent");
                adobeApiEventDef.appendChild(apiGeneratedEvent);

                Element apiDesc = outputObject.createElement("apiDesc");
                CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(fullDesc, "description", fullName));
                apiDesc.appendChild(cdata);
                adobeApiEventDetail.appendChild(apiDesc);

                asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
                shortdesc.setTextContent(asDocUtil.descToShortDesc(fullDesc));

                eventElement.setAttribute("fullname", fullName);

                processVersions(eventElement, adobeApiEvent);

                processCustoms(eventElement, adobeApiEvent, false, "", "", "");

                Element deprecatedNode = null;

                if (!eventElement.getAttribute("deprecatedMessage").equals(""))
                {
                    deprecatedNode = outputObject.createElement("apiDeprecated");
                    Element apiDesc2 = outputObject.createElement("apiDesc");
                    CDATASection cdata2 = outputObject.createCDATASection(eventElement.getAttribute("deprecatedMessage"));
                    apiDesc2.appendChild(cdata2);
                    deprecatedNode.appendChild(apiDesc2);
                    asDocUtil.convertDescToDITA(apiDesc2, oldNewNamesMap);
                }
                else if (!eventElement.getAttribute("deprecatedReplacement").equals(""))
                {
                    deprecatedNode = outputObject.createElement("apiDeprecated");
                    deprecatedNode.setAttribute("replacement", eventElement.getAttribute("deprecatedReplacement"));
                }

                if (deprecatedNode != null)
                {
                    if (!eventElement.getAttribute("deprecatedSince").equals(""))
                    {
                        deprecatedNode.setAttribute("sinceVersion", eventElement.getAttribute("deprecatedSince"));
                    }
                    adobeApiEventDef.appendChild(deprecatedNode);
                }

                childrenOfEvent = eventElement.getElementsByTagName("example");
                if (childrenOfEvent != null)
                {
                    for (int ix = 0; ix < childrenOfEvent.getLength(); ix++)
                    {
                        Element inputExampleElement = (Element)childrenOfEvent.item(ix);

                        Element example = outputObject.createElement("example");

                        CDATASection cdata2 = outputObject.createCDATASection(asDocUtil.validateText(inputExampleElement.getTextContent(), "example", fullName));
                        example.appendChild(cdata2);
                        adobeApiEvent.appendChild(example);
                        asDocUtil.convertDescToDITA(example, oldNewNamesMap);
                    }
                }

                if (myClass != null && eventElement != null)
                {
                    myClass.getNode().appendChild(adobeApiEvent);
                    if (verbose)
                    {
                        System.out.println("event handling for metadata added event " + name + " to class " + fullName);
                    }
                }
                else
                {
                    if (verbose)
                    {
                        System.out.println("*** Internal error: can't find class for event: " + fullName);
                    }
                }
            }

            Element bindableElement = asDocUtil.getElementByTagName((Element)parent, "Bindable");
            if (bindableElement != null)
            {
                // skip metadata if private
                NodeList childrenOfBindable = bindableElement.getElementsByTagName("private");
                if ((childrenOfBindable != null && childrenOfBindable.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                String fullName = bindableElement.getAttribute("owner");
                if (verbose)
                {
                    System.out.println(" processing bindable " + fullName);
                }
                
                String bindableEventName = bindableElement.getAttribute("name");

                AsClass myClass = classTable.get(fullName);

                if (myClass == null)
                {
                    QualifiedNameInfo qualifiedFullName = decomposeFullMethodOrFieldName(fullName);
                    myClass = classTable.get(qualifiedFullName.getFullClassName());
                    boolean found = false;
                    if (myClass != null && myClass.getFields() != null)
                    {
                        NodeList apiValueList = myClass.getFields().getChildNodes();

                        for (int ix = 0; ix < apiValueList.getLength(); ix++)
                        {
                            Element apiValueElement = (Element)apiValueList.item(ix);
                            if (apiValueElement.getAttribute("id").equals(asDocUtil.formatId(fullName)))
                            {

                                Element apiValueDetail = null;
                                Element apiValueDef = null;
                                Element apiProperty = null;

                                NodeList apiValueDetailList = apiValueElement.getElementsByTagName("apiValueDetail");
                                if (apiValueDetailList != null && apiValueDetailList.getLength() != 0)
                                {
                                    apiValueDetail = (Element)apiValueDetailList.item(0);

                                    NodeList apiValueDefList = apiValueDetail.getElementsByTagName("apiValueDef");
                                    if (apiValueDefList != null && apiValueDefList.getLength() != 0)
                                    {
                                        apiValueDef = (Element)apiValueDefList.item(0);

                                        NodeList apiPropertyList = apiValueDef.getElementsByTagName("apiProperty");
                                        if (apiPropertyList != null && apiPropertyList.getLength() != 0)
                                        {
                                            apiProperty = (Element)apiPropertyList.item(0);
                                            if (apiProperty.getAttribute("isBindable").equals("") || !apiProperty.getAttribute("isBindable").equals("true"))
                                            {
                                                apiProperty.setAttribute("isBindable", "true");
                                                
                                                if (!bindableEventName.equals(""))
                                                {
                                                    apiProperty.setAttribute("name", bindableEventName);  
                                                }
                                                
                                                found = true;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            apiProperty = outputObject.createElement("apiProperty");
                                            apiProperty.setAttribute("isBindable", "true");
                                            
                                            if (!bindableEventName.equals(""))
                                            {
                                                apiProperty.setAttribute("name", bindableEventName);  
                                            }

                                            apiValueDef.appendChild(apiProperty);
                                            found = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        apiProperty = outputObject.createElement("apiProperty");
                                        apiProperty.setAttribute("isBindable", "true");
                                        
                                        if (!bindableEventName.equals(""))
                                        {
                                            apiProperty.setAttribute("name", bindableEventName);  
                                        }
                                        
                                        apiValueDef = outputObject.createElement("apiValueDef");
                                        apiValueDef.appendChild(apiProperty);

                                        apiValueDetail.appendChild(apiValueDef);
                                        found = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    apiProperty = outputObject.createElement("apiProperty");
                                    apiProperty.setAttribute("isBindable", "true");
                                    
                                    if (!bindableEventName.equals(""))
                                    {
                                        apiProperty.setAttribute("name", bindableEventName);  
                                    }

                                    apiValueDef = outputObject.createElement("apiValueDef");
                                    apiValueDetail = outputObject.createElement("apiValueDetail");

                                    apiValueDetail.appendChild(apiValueDef);
                                    apiValueDef.appendChild(apiProperty);
                                    apiValueElement.appendChild(apiValueDetail);
                                    found = true;
                                    break;
                                }

                            }
                        }

                    }

                    if (!found)
                    {
                        bindableTable.put(fullName, "isBindable");
                    }
                }
                else
                {
                    bindableTable.put(fullName, "isBindable");
                }
            }

            Element defaultPropertyElement = asDocUtil.getElementByTagName((Element)parent, "DefaultProperty");
            if (defaultPropertyElement != null)
            {
                String fullName = defaultPropertyElement.getAttribute("owner");

                AsClass myClass = classTable.get(fullName);

                if (myClass != null)
                {

                    Element node = myClass.getNode();
                    Element asMetadata = null;

                    Element defaultProperty = outputObject.createElement("DefaultProperty");
                    defaultProperty.setAttribute("name", defaultPropertyElement.getAttribute("name"));
                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null)
                    {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                        if (asMetadata != null)
                        {
                            asMetadata.appendChild(defaultProperty);
                        }
                        else
                        {
                            asMetadata = outputObject.createElement("asMetadata");
                            asMetadata.appendChild(defaultProperty);
                            prolog.appendChild(asMetadata);
                        }
                    }
                    else
                    {
                        asMetadata = outputObject.createElement("asMetadata");
                        asMetadata.appendChild(defaultProperty);

                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);

                        myClass.getNode().appendChild(prolog);
                    }
                }
            }

            Element deprecatedElement = asDocUtil.getElementByTagName((Element)parent, "Deprecated");
            if (deprecatedElement != null)
            {
                String fullName = deprecatedElement.getAttribute("owner");

                if (verbose)
                {
                    System.out.println(" processing deprecated " + fullName);
                }

                AsClass myClass = classTable.get(fullName);
                Node node = null;

                if (myClass != null)
                {
                    node = myClass.getNode();
                }
                else
                {
                    QualifiedNameInfo qualifiedFullName = decomposeFullMethodOrFieldName(fullName);
                    myClass = classTable.get(qualifiedFullName.getFullClassName());
                    if (myClass != null)
                    {
                        if (myClass.getFields() != null)
                        {
                            NodeList childNodeList = myClass.getFields().getElementsByTagName("apiValue");
                            for (int ix = 0; ix < childNodeList.getLength(); ix++)
                            {
                                Element childElement = (Element)childNodeList.item(ix);
                                if (childElement.getAttribute("id").equals(asDocUtil.formatId(fullName)))
                                {
                                    node = childElement;
                                    break;
                                }
                            }
                        }

                        if (node == null && myClass.getMethods() != null)
                        {
                            NodeList childNodeList = myClass.getMethods().getElementsByTagName("apiOperation");
                            for (int ix = 0; ix < childNodeList.getLength(); ix++)
                            {
                                Element childElement = (Element)childNodeList.item(ix);
                                if (childElement.getAttribute("id").equals(asDocUtil.formatId(fullName)))
                                {
                                    node = childElement;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (verbose)
                        {
                            System.out.println("   did not find my class for : " + qualifiedFullName.getFullClassName());
                        }
                    }
                }

                if (node == null)
                {
                    return;
                }

                Element defNode = asDocUtil.getDefNode((Element)node);

                Element apiDeprecated = outputObject.createElement("apiDeprecated");

                if (!deprecatedElement.getAttribute("replacement").equals(""))
                {
                    apiDeprecated.setAttribute("replacement", deprecatedElement.getAttribute("replacement"));
                }
                else if (!deprecatedElement.getAttribute("message").equals(""))
                {
                    Element apiDesc = outputObject.createElement("apiDesc");
                    CDATASection cdata = outputObject.createCDATASection(deprecatedElement.getAttribute("message"));
                    apiDesc.appendChild(cdata);
                    apiDeprecated.appendChild(apiDesc);
                    asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
                }
                else if (!deprecatedElement.getAttribute("name").equals(""))
                {
                    Element apiDesc = outputObject.createElement("apiDesc");
                    CDATASection cdata = outputObject.createCDATASection(deprecatedElement.getAttribute("name"));
                    apiDesc.appendChild(cdata);
                    apiDeprecated.appendChild(apiDesc);
                    asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
                }

                if (!deprecatedElement.getAttribute("since").equals(""))
                {
                    apiDeprecated.setAttribute("sinceVersion", deprecatedElement.getAttribute("since"));
                }

                defNode.appendChild(apiDeprecated);
            }

            Element skinStateElement = asDocUtil.getElementByTagName((Element)parent, "SkinState");
            if (skinStateElement != null)
            {
                // skip metadata if private
                NodeList childrenOfSkinState = skinStateElement.getElementsByTagName("private");
                if ((childrenOfSkinState != null && childrenOfSkinState.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                String fullName = skinStateElement.getAttribute("owner");
                String name = skinStateElement.getAttribute("name");

                AsClass myClass = classTable.get(fullName);

                if (myClass != null)
                {
                    Element node = myClass.getNode();

                    Element skinStatesElement = null;
                    Element asMetadata = null;
                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null)
                    {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
                        if (asMetadata != null)
                        {
                            HashMap<String, String> attributes = new HashMap<String, String>();
                            attributes.put("kind", "SkinState");
                            attributes.put("name", name);
                            
                            Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                            if (excludeElement != null)
                            {
                                if (verbose)
                                {
                                    System.out.println("Excluding SkinState " + name + " from " + myClass.getName());
                                }
                                return;
                            }

                            skinStatesElement = asDocUtil.getElementByTagName(asMetadata, "skinStates");
                            if (skinStatesElement == null)
                            {
                                skinStatesElement = outputObject.createElement("skinStates");
                                asMetadata.appendChild(skinStatesElement);
                            }
                        }
                        else
                        {
                            skinStatesElement = outputObject.createElement("skinStates");
                            asMetadata = outputObject.createElement("asMetadata");
                            asMetadata.appendChild(skinStatesElement);
                            prolog.appendChild(asMetadata);
                        }
                    }
                    else
                    {
                        skinStatesElement = outputObject.createElement("skinStates");
                        asMetadata = outputObject.createElement("asMetadata");
                        asMetadata.appendChild(skinStatesElement);

                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);

                        myClass.getNode().appendChild(prolog);
                    }

                    Element newSkinStateElement = (Element)outputObject.importNode(skinStateElement, true);

                    asDocUtil.processCustoms(newSkinStateElement, outputObject);

                    childrenOfSkinState = newSkinStateElement.getElementsByTagName("default");
                    if (childrenOfSkinState != null && childrenOfSkinState.getLength() != 0)
                    {
                        Element defaultElement = (Element)childrenOfSkinState.item(0);
                        String defaultText = defaultElement.getTextContent();

                        Element newDefaultElement = outputObject.createElement("default");
                        newDefaultElement.setTextContent(defaultText);

                        newSkinStateElement.replaceChild(newDefaultElement, defaultElement);
                    }

                    NodeList descriptionList = newSkinStateElement.getElementsByTagName("description");
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        Element descriptionElement = (Element)descriptionList.item(0);
                        String descriptionText = descriptionElement.getTextContent();

                        Element newDescriptionElement = outputObject.createElement("description");
                        CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                        newDescriptionElement.appendChild(cdata);

                        newSkinStateElement.replaceChild(newDescriptionElement, descriptionElement);
                        asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                    }

                    childrenOfSkinState = newSkinStateElement.getElementsByTagName("see");
                    if (childrenOfSkinState != null && childrenOfSkinState.getLength() != 0)
                    {
                        Element relatedLinks = outputObject.createElement("related-links");
                        for (int ix = 0; ix < childrenOfSkinState.getLength(); ix++)
                        {
                            Element seeElement = (Element)childrenOfSkinState.item(ix);
                            relatedLinks.appendChild(processSeeTag(fullName, seeElement.getTextContent()));
                        }
                        newSkinStateElement.appendChild(relatedLinks);

                        for (int ix = 0; ix < childrenOfSkinState.getLength(); ix++)
                        {
                            newSkinStateElement.removeChild(childrenOfSkinState.item(ix));
                        }

                    }

                    childrenOfSkinState = newSkinStateElement.getElementsByTagName("copy");
                    if (childrenOfSkinState != null && childrenOfSkinState.getLength() != 0)
                    {
                        String text = childrenOfSkinState.item(0).getTextContent();
                        text = text.replaceAll("\\s+", "");

                        descriptionList = newSkinStateElement.getElementsByTagName("description");
                        Element descriptionElement = null;
                        if (descriptionList != null && descriptionList.getLength() != 0)
                        {
                            descriptionElement = (Element)descriptionList.item(0);
                        }
                        else
                        {
                            descriptionElement = outputObject.createElement("description");
                            newSkinStateElement.appendChild(descriptionElement);
                        }
                        descriptionElement.setAttribute("conref", text);

                        newSkinStateElement.removeChild(childrenOfSkinState.item(0));
                    }

                    childrenOfSkinState = newSkinStateElement.getElementsByTagName("playerversion");
                    if (childrenOfSkinState != null && childrenOfSkinState.getLength() != 0)
                    {
                        String playerversion = childrenOfSkinState.item(0).getTextContent();
                        playerversion = playerversion.replaceAll("\\s+", "");

                        newSkinStateElement.setAttribute("playerVersion", playerversion);
                        newSkinStateElement.removeChild(childrenOfSkinState.item(0));
                    }

                    skinStatesElement.appendChild(newSkinStateElement);
                }
            }

            Element skinPartElement = asDocUtil.getElementByTagName((Element)parent, "SkinPart");
            if (skinPartElement != null)
            {
                // skip metadata if private
                NodeList childrenOfSkinPart = skinPartElement.getElementsByTagName("private");
                if ((childrenOfSkinPart != null && childrenOfSkinPart.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                String fullName = skinPartElement.getAttribute("owner");
                String name = skinPartElement.getAttribute("name");

                AsClass myClass = classTable.get(fullName);

                if (myClass != null)
                {
                    Element node = myClass.getNode();

                    Element skinPartsElement = null;
                    Element asMetadata = null;
                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null)
                    {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
                        if (asMetadata != null)
                        {
                            HashMap<String, String> attributes = new HashMap<String, String>();
                            attributes.put("kind", "SkinPart");
                            attributes.put("name", name);
                            
                            Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                            if (excludeElement != null)
                            {
                                if (verbose)
                                {
                                    System.out.println("Excluding SkinPart " + name + " from " + myClass.getName());
                                }
                                return;
                            }

                            skinPartsElement = asDocUtil.getElementByTagName(asMetadata, "skinParts");
                            if (skinPartsElement == null)
                            {
                                skinPartsElement = outputObject.createElement("skinParts");
                                asMetadata.appendChild(skinPartsElement);
                            }
                        }
                        else
                        {
                            skinPartsElement = outputObject.createElement("skinParts");
                            asMetadata = outputObject.createElement("asMetadata");
                            asMetadata.appendChild(skinPartsElement);
                            prolog.appendChild(asMetadata);
                        }
                    }
                    else
                    {
                        skinPartsElement = outputObject.createElement("skinParts");
                        asMetadata = outputObject.createElement("asMetadata");
                        asMetadata.appendChild(skinPartsElement);

                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);

                        myClass.getNode().appendChild(prolog);
                    }

                    Element newSkinPartElement = (Element)outputObject.importNode(skinPartElement, true);

                    asDocUtil.processCustoms(newSkinPartElement, outputObject);

                    childrenOfSkinPart = newSkinPartElement.getElementsByTagName("default");
                    if (childrenOfSkinPart != null && childrenOfSkinPart.getLength() != 0)
                    {
                        Element defaultElement = (Element)childrenOfSkinPart.item(0);
                        String defaultText = defaultElement.getTextContent();

                        Element newDefaultElement = outputObject.createElement("default");
                        newDefaultElement.setTextContent(defaultText);

                        newSkinPartElement.replaceChild(newDefaultElement, defaultElement);
                    }

                    NodeList descriptionList = newSkinPartElement.getElementsByTagName("description");
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        Element descriptionElement = (Element)descriptionList.item(0);
                        String descriptionText = descriptionElement.getTextContent();

                        Element shortdesc = outputObject.createElement("shortdesc");
                        newSkinPartElement.appendChild(shortdesc);
                        shortdesc.setTextContent(asDocUtil.descToShortDesc(descriptionText));
                        
                        Element newDescriptionElement = outputObject.createElement("description");
                        CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                        newDescriptionElement.appendChild(cdata);

                        newSkinPartElement.replaceChild(newDescriptionElement, descriptionElement);
                        asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                    }

                    childrenOfSkinPart = newSkinPartElement.getElementsByTagName("see");
                    if (childrenOfSkinPart != null && childrenOfSkinPart.getLength() != 0)
                    {
                        Element relatedLinks = outputObject.createElement("related-links");
                        for (int ix = 0; ix < childrenOfSkinPart.getLength(); ix++)
                        {
                            Element seeElement = (Element)childrenOfSkinPart.item(ix);
                            relatedLinks.appendChild(processSeeTag(fullName, seeElement.getTextContent()));
                        }
                        newSkinPartElement.appendChild(relatedLinks);

                        for (int ix = 0; ix < childrenOfSkinPart.getLength(); ix++)
                        {
                            newSkinPartElement.removeChild(childrenOfSkinPart.item(ix));
                        }

                    }

                    childrenOfSkinPart = newSkinPartElement.getElementsByTagName("copy");
                    if (childrenOfSkinPart != null && childrenOfSkinPart.getLength() != 0)
                    {
                        String text = childrenOfSkinPart.item(0).getTextContent();
                        text = text.replaceAll("\\s+", "");

                        descriptionList = newSkinPartElement.getElementsByTagName("description");
                        Element descriptionElement = null;
                        if (descriptionList != null && descriptionList.getLength() != 0)
                        {
                            descriptionElement = (Element)descriptionList.item(0);
                        }
                        else
                        {
                            descriptionElement = outputObject.createElement("description");
                            newSkinPartElement.appendChild(descriptionElement);
                        }
                        descriptionElement.setAttribute("conref", text);

                        newSkinPartElement.removeChild(childrenOfSkinPart.item(0));
                    }

                    childrenOfSkinPart = newSkinPartElement.getElementsByTagName("playerversion");
                    if (childrenOfSkinPart != null && childrenOfSkinPart.getLength() != 0)
                    {
                        String playerversion = childrenOfSkinPart.item(0).getTextContent();
                        playerversion = playerversion.replaceAll("\\s+", "");

                        newSkinPartElement.setAttribute("playerVersion", playerversion);
                        newSkinPartElement.removeChild(childrenOfSkinPart.item(0));
                    }

                    skinPartsElement.appendChild(newSkinPartElement);
                }
            }

            Element alternativeElement = asDocUtil.getElementByTagName((Element)parent, "Alternative");
            if (alternativeElement != null)
            {
                String fullName = alternativeElement.getAttribute("owner");

                AsClass myClass = classTable.get(fullName);

                if (myClass != null)
                {
                    Element node = myClass.getNode();
                    Element asMetadata = null;

                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null)
                    {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");

                        if (asMetadata == null)
                        {
                            asMetadata = outputObject.createElement("asMetadata");
                            prolog.appendChild(asMetadata);
                        }
                    }
                    else
                    {
                        asMetadata = outputObject.createElement("asMetadata");

                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);

                        myClass.getNode().appendChild(prolog);
                    }

                    Element alternative = (Element)outputObject.importNode(alternativeElement, true);

                    asDocUtil.processCustoms(alternative, outputObject);

                    NodeList descriptionList = alternative.getElementsByTagName("description");
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        Element descriptionElement = (Element)descriptionList.item(0);
                        String descriptionText = descriptionElement.getTextContent();

                        Element newDescriptionElement = outputObject.createElement("description");
                        CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                        newDescriptionElement.appendChild(cdata);

                        alternative.replaceChild(newDescriptionElement, descriptionElement);
                        asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                    }

                    NodeList childrenOfAlternative = alternative.getElementsByTagName("see");
                    if (childrenOfAlternative != null && childrenOfAlternative.getLength() != 0)
                    {
                        Element relatedLinks = outputObject.createElement("related-links");
                        for (int ix = 0; ix < childrenOfAlternative.getLength(); ix++)
                        {
                            Element seeElement = (Element)childrenOfAlternative.item(ix);
                            relatedLinks.appendChild(processSeeTag(fullName, seeElement.getTextContent()));
                        }
                        alternative.appendChild(relatedLinks);

                        for (int ix = 0; ix < childrenOfAlternative.getLength(); ix++)
                        {
                            alternative.removeChild(childrenOfAlternative.item(ix));
                        }

                    }

                    childrenOfAlternative = alternative.getElementsByTagName("copy");
                    if (childrenOfAlternative != null && childrenOfAlternative.getLength() != 0)
                    {
                        String text = childrenOfAlternative.item(0).getTextContent();
                        text = text.replaceAll("\\s+", "");

                        descriptionList = alternative.getElementsByTagName("description");
                        Element descriptionElement = null;
                        if (descriptionList != null && descriptionList.getLength() != 0)
                        {
                            descriptionElement = (Element)descriptionList.item(0);
                        }
                        else
                        {
                            descriptionElement = outputObject.createElement("description");
                            alternative.appendChild(descriptionElement);
                        }
                        descriptionElement.setAttribute("conref", text);

                        alternative.removeChild(childrenOfAlternative.item(0));
                    }

                    asMetadata.appendChild(alternative);
                }
            }

                  /* adding experimental XML */
            Element experimentalElement = asDocUtil.getElementByTagName((Element) parent, StandardDefs.MD_EXPERIMENTAL);
            if (experimentalElement != null) {
                String fullName = experimentalElement.getAttribute("owner");

                if (verbose)
                {
                    System.out.println(" processing [Experimental] for " + fullName);
                }

                AsClass myClass = classTable.get(fullName);

                if (myClass != null) {
                    Element node = myClass.getNode();

                    Element profilesElement = null;
                    Element asMetadata = null;
                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null) {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
                        if (asMetadata != null) {
                           profilesElement = asDocUtil.getElementByTagName(asMetadata, "experimental");
                            if (profilesElement == null) {
                                profilesElement = outputObject.createElement("experimental");
                                asMetadata.appendChild(profilesElement);
                            }
                        } else {
                            profilesElement = outputObject.createElement("discouragedForProfiles");
                            asMetadata = outputObject.createElement("asMetadata");
                            asMetadata.appendChild(profilesElement);
                            prolog.appendChild(asMetadata);
                        }
                    } else {
                        profilesElement = outputObject.createElement("discouragedForProfiles");
                        asMetadata = outputObject.createElement("asMetadata");
                        asMetadata.appendChild(profilesElement);
                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);
                        myClass.getNode().appendChild(prolog);
                    }

                }

        }
            
            Element discouragedForProfileElement = asDocUtil.getElementByTagName((Element)parent, "DiscouragedForProfile");
            if (discouragedForProfileElement != null)
            {
                // skip metadata if private
                NodeList childrenOfDiscouragedForProfile = discouragedForProfileElement.getElementsByTagName("private");
                if ((childrenOfDiscouragedForProfile != null && childrenOfDiscouragedForProfile.getLength() != 0) && !includePrivate)
                {
                    return;
                }

                String fullName = discouragedForProfileElement.getAttribute("owner");
                String name = discouragedForProfileElement.getAttribute("name");

                AsClass myClass = classTable.get(fullName);

                if (myClass != null)
                {
                    Element node = myClass.getNode();

                    Element profilesElement = null;
                    Element asMetadata = null;
                    Element prolog = asDocUtil.getElementByTagName(node, "prolog");
                    if (prolog != null)
                    {
                        asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
                        if (asMetadata != null)
                        {
                            HashMap<String, String> attributes = new HashMap<String, String>();
                            attributes.put("kind", "DiscouragedForProfile");
                            attributes.put("name", name);
                            
                            Element excludeElement = asDocUtil.getElementByTagNameAndMatchingAttributes(asMetadata, "Exclude", attributes.entrySet());
                            if (excludeElement != null)
                            {
                                if (verbose)
                                {
                                    System.out.println("Excluding DiscouragedForProfile " + name + " from " + myClass.getName());
                                }
                                return;
                            }

                            profilesElement = asDocUtil.getElementByTagName(asMetadata, "discouragedForProfiles");
                            if (profilesElement == null)
                            {
                            		profilesElement = outputObject.createElement("discouragedForProfiles");
                                asMetadata.appendChild(profilesElement);
                            }
                        }
                        else
                        {
                        		profilesElement = outputObject.createElement("discouragedForProfiles");
                            asMetadata = outputObject.createElement("asMetadata");
                            asMetadata.appendChild(profilesElement);
                            prolog.appendChild(asMetadata);
                        }
                    }
                    else
                    {
                    		profilesElement = outputObject.createElement("discouragedForProfiles");
                        asMetadata = outputObject.createElement("asMetadata");
                        asMetadata.appendChild(profilesElement);

                        prolog = outputObject.createElement("prolog");
                        prolog.appendChild(asMetadata);

                        myClass.getNode().appendChild(prolog);
                    }

                    Element discouragedForProfile = (Element)outputObject.importNode(discouragedForProfileElement, true);

                    asDocUtil.processCustoms(discouragedForProfile, outputObject);

                    NodeList descriptionList = discouragedForProfile.getElementsByTagName("description");
                    if (descriptionList != null && descriptionList.getLength() != 0)
                    {
                        Element descriptionElement = (Element)descriptionList.item(0);
                        String descriptionText = descriptionElement.getTextContent();

                        Element newDescriptionElement = outputObject.createElement("description");
                        CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(descriptionText, "description", fullName));
                        newDescriptionElement.appendChild(cdata);

                        discouragedForProfile.replaceChild(newDescriptionElement, descriptionElement);
                        asDocUtil.convertDescToDITA(newDescriptionElement, oldNewNamesMap);
                    }

                    NodeList childrenOfDiscouragedForProfiles = discouragedForProfile.getElementsByTagName("see");
                    if (childrenOfDiscouragedForProfiles != null && childrenOfDiscouragedForProfiles.getLength() != 0)
                    {
                        Element relatedLinks = outputObject.createElement("related-links");
                        for (int ix = 0; ix < childrenOfDiscouragedForProfiles.getLength(); ix++)
                        {
                            Element seeElement = (Element)childrenOfDiscouragedForProfiles.item(ix);
                            relatedLinks.appendChild(processSeeTag(fullName, seeElement.getTextContent()));
                        }
                        discouragedForProfile.appendChild(relatedLinks);

                        for (int ix = 0; ix < childrenOfDiscouragedForProfiles.getLength(); ix++)
                        {
                        	discouragedForProfile.removeChild(childrenOfDiscouragedForProfiles.item(ix));
                        }

                    }

                    childrenOfDiscouragedForProfiles = discouragedForProfile.getElementsByTagName("copy");
                    if (childrenOfDiscouragedForProfiles != null && childrenOfDiscouragedForProfiles.getLength() != 0)
                    {
                        String text = childrenOfDiscouragedForProfiles.item(0).getTextContent();
                        text = text.replaceAll("\\s+", "");

                        descriptionList = discouragedForProfile.getElementsByTagName("description");
                        Element descriptionElement = null;
                        if (descriptionList != null && descriptionList.getLength() != 0)
                        {
                            descriptionElement = (Element)descriptionList.item(0);
                        }
                        else
                        {
                            descriptionElement = outputObject.createElement("description");
                            discouragedForProfile.appendChild(descriptionElement);
                        }
                        descriptionElement.setAttribute("conref", text);

                        discouragedForProfile.removeChild(childrenOfDiscouragedForProfiles.item(0));
                    }

                    profilesElement.appendChild(discouragedForProfile);
                }
            }   
        }
    }