Example usage for org.w3c.dom NamedNodeMap getLength

List of usage examples for org.w3c.dom NamedNodeMap getLength

Introduction

In this page you can find the example usage for org.w3c.dom NamedNodeMap getLength.

Prototype

public int getLength();

Source Link

Document

The number of nodes in this map.

Usage

From source file:eu.elf.license.LicenseParser.java

/**
 * Creates List of LicenseModelGroup objects
 *
 * @param productGroupElementList - List of <ns:productGroup> elements
 * @return list of LicenseModelGroup objects
 *//*from w w  w  .  ja v  a2  s  .c  o m*/
private static List<LicenseModelGroup> createLicenseModelGroupList(NodeList productGroupElementList) {
    List<LicenseModelGroup> lmgList = new ArrayList<LicenseModelGroup>();

    for (int i = 0; i < productGroupElementList.getLength(); i++) {
        LicenseModelGroup tempLMG = new LicenseModelGroup();
        Boolean isAccountGroup = false;

        Element productGroupElement = (Element) productGroupElementList.item(i);

        NamedNodeMap productGroupElementAttributeMap = productGroupElement.getAttributes();

        for (int j = 0; j < productGroupElementAttributeMap.getLength(); j++) {
            Attr attrs = (Attr) productGroupElementAttributeMap.item(j);

            if (attrs.getNodeName().equals("id")) {

                if (attrs.getNodeValue().equals("ACCOUNTING_SUMMARY_GROUP")) { // Skip element with id="ACCOUNTING_SUMMARY_GROUP" -  do not add to the list
                    isAccountGroup = true;
                }

                if (attrs.getNodeName() != null) {
                    tempLMG.setId(attrs.getNodeValue());
                }
            }
            if (attrs.getNodeName().equals("name")) {
                if (attrs.getNodeName() != null) {
                    tempLMG.setUrl(attrs.getNodeValue());
                }
            }
        }

        if (isAccountGroup == true) {
            continue; // Skip element with id="ACCOUNTING_SUMMARY_GROUP" -  do not add to the list
        }

        Element abstractElement = (Element) productGroupElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "abstract").item(0);
        if (abstractElement != null) {
            tempLMG.setDescription(abstractElement.getTextContent());
        }

        Element titleElement = (Element) productGroupElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "title").item(0);
        if (titleElement != null) {
            tempLMG.setName(titleElement.getTextContent());
        }

        NodeList productElementList = productGroupElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "product");
        tempLMG.setLicenseModels(createLicenseModelList(productElementList));

        lmgList.add(tempLMG);
    }

    return lmgList;
}

From source file:eu.elf.license.LicenseParser.java

/**
 * Creates LicenseConcludeResponseObject from the concludeLicense operation's response string
 * /*w  w w. ja  va 2s .c  o  m*/
 * @param response
 * @return
 * @throws Exception
 */
public static LicenseConcludeResponseObject parseConcludeLicenseResponse(String response) throws Exception {
    LicenseConcludeResponseObject lcro = new LicenseConcludeResponseObject();

    try {
        Document xmlDoc = LicenseParser.createXMLDocumentFromString(response);
        NodeList LicenseReferenceNL = xmlDoc.getElementsByTagNameNS("http://www.52north.org/license/0.3.2",
                "LicenseReference");

        for (int i = 0; i < LicenseReferenceNL.getLength(); i++) {
            Element attributeStatementElement = (Element) LicenseReferenceNL.item(i);

            NodeList attributeElementList = attributeStatementElement
                    .getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "Attribute");

            for (int j = 0; j < attributeElementList.getLength(); j++) {
                Element attributeElement = (Element) attributeElementList.item(j);
                Element AttributeValueElement = (Element) attributeElement
                        .getElementsByTagName("AttributeValue").item(0);

                NamedNodeMap licenseReferenceElementAttributeMap = attributeElement.getAttributes();

                for (int k = 0; k < licenseReferenceElementAttributeMap.getLength(); k++) {
                    Attr attrs = (Attr) licenseReferenceElementAttributeMap.item(k);

                    if (attrs.getNodeName().equals("Name")) {
                        if (attrs.getNodeValue().equals("urn:opengeospatial:ows4:geodrm:NotOnOrAfter")) {
                            lcro.setValidTo(AttributeValueElement.getTextContent());
                        }
                        if (attrs.getNodeValue().equals("urn:opengeospatial:ows4:geodrm:ProductID")) {
                            lcro.setProductId(AttributeValueElement.getTextContent());
                        }
                        if (attrs.getNodeValue().equals("urn:opengeospatial:ows4:geodrm:LicenseID")) {
                            lcro.setLicenseId(AttributeValueElement.getTextContent());
                        }
                    }

                }

            }

        }

    } catch (Exception e) {
        throw e;
    }

    return lcro;
}

From source file:bridge.toolkit.commands.S1000DConverter.java

/**
 * Receive the node with the refdm, returns the dm file name
 * /*www . j  ava 2  s. c o  m*/
 * @param e
 * @return
 */
public static String gettingDmfilename(Node theAncestor) {
    String dmc = "";
    String modelIdentCode = "";
    String systemDiffCode = "";
    String systemCode = "";
    String subSystemCode = "";
    String subSubSystemCode = "";
    String assyCode = "";
    String disassyCode = "";
    String disassyCodeVariant = "";
    String infoCode = "";
    String infoCodeVariant = "";
    String itemLocationCode = "";
    String learnCode = "";
    String learnEventCode = "";

    String countryIsoCode = "";
    String languageIsoCode = "";
    String issueinfo = "";
    String inwork = "";

    Node e = null;
    // looking for dmCode...
    for (int sons = 0; sons < theAncestor.getChildNodes().getLength(); sons++) {
        if (theAncestor.getChildNodes().item(sons) != null
                && theAncestor.getChildNodes().item(sons).getNodeName().equals("dmRefIdent")) {
            for (int sons2 = 0; sons2 < theAncestor.getChildNodes().item(sons).getChildNodes()
                    .getLength(); sons2++) {
                if (theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2) != null
                        && theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2).getNodeName()
                                .equals("dmCode")) {
                    e = theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2);
                    // building the file name structure
                    dmc = "DMC-";
                    NamedNodeMap atts = e.getAttributes();
                    for (int i = 0; i < atts.getLength(); i++) {
                        if (atts.item(i).getNodeName() == "modelIdentCode")
                            modelIdentCode = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "systemDiffCode")
                            systemDiffCode = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "systemCode")
                            systemCode = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "subSystemCode")
                            subSystemCode = atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "subSubSystemCode")
                            subSubSystemCode = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "assyCode")
                            assyCode = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "disassyCode")
                            disassyCode = atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "disassyCodeVariant")
                            disassyCodeVariant = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "infoCode")
                            infoCode = atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "infoCodeVariant")
                            infoCodeVariant = atts.item(i).getNodeValue() + "-";

                        if (atts.item(i).getNodeName() == "itemLocationCode")
                            if (atts.getLength() > 11)
                                itemLocationCode = atts.item(i).getNodeValue() + "-";
                            else
                                itemLocationCode = atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "learnCode")
                            learnCode = atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "learnEventCode")
                            learnEventCode = atts.item(i).getNodeValue();
                    }
                }

                if (theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2) != null
                        && theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2).getNodeName()
                                .equals("language")) {
                    e = theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2);
                    NamedNodeMap atts = e.getAttributes();
                    for (int i = 0; i < atts.getLength(); i++) {
                        if (atts.item(i).getNodeName() == "countryIsoCode")
                            countryIsoCode = "-" + atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "languageIsoCode")
                            languageIsoCode = "_" + atts.item(i).getNodeValue();
                    }

                }

                if (theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2) != null
                        && theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2).getNodeName()
                                .equals("issueInfo")) {
                    e = theAncestor.getChildNodes().item(sons).getChildNodes().item(sons2);
                    NamedNodeMap atts = e.getAttributes();
                    for (int i = 0; i < atts.getLength(); i++) {
                        if (atts.item(i).getNodeName() == "issueNumber")
                            issueinfo = "_" + atts.item(i).getNodeValue();

                        if (atts.item(i).getNodeName() == "inWork")
                            inwork = "-" + atts.item(i).getNodeValue();
                    }

                }

            }
            if (e != null)
                break;
        }
    }

    if (e == null)
        return "";
    return dmc + modelIdentCode + systemDiffCode + systemCode + subSystemCode + subSubSystemCode + assyCode
            + disassyCode + disassyCodeVariant + infoCode + infoCodeVariant + itemLocationCode + learnCode
            + learnEventCode + issueinfo + inwork + languageIsoCode + countryIsoCode;
}

From source file:AndroidUninstallStock.java

public static HashMap<String, String> getXmlAttributes(Node node) {
    HashMap<String, String> res = new HashMap<String, String>();
    NamedNodeMap attrs = node.getAttributes();
    if (attrs == null) {
        return res;
    }/*from www  .j  a v  a 2  s .  co m*/
    for (int x = attrs.getLength() - 1; x > -1; x--) {
        res.put(attrs.item(x).getNodeName(), attrs.item(x).getNodeValue());
    }
    return res;
}

From source file:eu.elf.license.LicenseParser.java

public static UserLicenses parseUserLicensesAsLicenseModelGroupList(String xml, String userid)
        throws Exception {
    UserLicenses userLicenses = new UserLicenses();

    try {/*www  .j  a  v  a2s.c  om*/
        Document xmlDoc = createXMLDocumentFromString(xml);

        Element ordersElement = (Element) xmlDoc
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "orders").item(0);
        NodeList orderList = ordersElement.getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "order");

        for (int i = 0; i < orderList.getLength(); i++) {
            UserLicense userLicense = new UserLicense();
            try {
                Element orderElement = (Element) orderList.item(i);
                Element productionElement = (Element) orderElement
                        .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "production").item(0);
                Element productionItemElement = (Element) productionElement
                        .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "productionItem").item(0);
                Element LicenseReferenceElement = (Element) productionItemElement
                        .getElementsByTagNameNS("http://www.52north.org/license/0.3.2", "LicenseReference")
                        .item(0);
                Element attributeStatementElement = (Element) LicenseReferenceElement
                        .getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "AttributeStatement")
                        .item(0);

                NodeList attributeElementList = attributeStatementElement
                        .getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "Attribute");

                for (int j = 0; j < attributeElementList.getLength(); j++) {
                    Element attributeElement = (Element) attributeElementList.item(j);
                    Element AttributeValueElement = (Element) attributeElement
                            .getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "AttributeValue")
                            .item(0);

                    NamedNodeMap attributeMap = attributeElement.getAttributes();
                    for (int k = 0; k < attributeMap.getLength(); k++) {
                        Attr attrs = (Attr) attributeMap.item(k);
                        if ("Name".equals(attrs.getNodeName())) {

                            if ("urn:opengeospatial:ows4:geodrm:NotOnOrAfter".equals(attrs.getNodeValue())) {
                                userLicense.setValidTo(AttributeValueElement.getTextContent());
                            }
                            if ("urn:opengeospatial:ows4:geodrm:LicenseID".equals(attrs.getNodeValue())) {
                                userLicense.setLicenseId(AttributeValueElement.getTextContent());
                            }
                        }
                    }
                    userLicense.setSecureServiceURL("/httpauth/licid-" + userLicense.getLicenseId());
                }

                Element orderContentElement = (Element) orderElement
                        .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "orderContent").item(0);
                Element catalogElement = (Element) orderContentElement
                        .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "catalog").item(0);
                NodeList productGroupElementList = catalogElement
                        .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "productGroup");

                // setup user license flags in models
                List<LicenseModelGroup> list = createLicenseModelGroupList(productGroupElementList);
                for (LicenseModelGroup group : list) {
                    group.setUserLicense(true);
                }
                userLicense.setLmgList(list);

                String WSS_URL = findWssUrlFromUserLicenseParamList(userLicense.getLmgList());

                //Remove WSS from the WSS-url string
                WSS_URL = WSS_URL.substring(0, WSS_URL.lastIndexOf("/"));

                userLicense.setSecureServiceURL(WSS_URL + userLicense.getSecureServiceURL());

                userLicenses.addUserLicense(userLicense);
            } catch (Exception e) {
                // Sometimes we get results without LicenseReference element: order/production/productionItem/LicenseReference
                // there might be valid results in the same response. Skipping the invalid ones.
                LOG.warn("Error while parsing user licenses");
            }

        }

        return userLicenses;

    } catch (Exception e) {
        throw e;
    }
}

From source file:eu.elf.license.LicenseParser.java

/**
 * Creates list of LicenseModel elements
 *
 * @param productElementList - NodeList of <ns:product> elements:
 * @return List of LicenseModel objects//from  w  w w.j av  a 2  s  .  c  om
 */
private static List<LicenseModel> createLicenseModelList(NodeList productElementList) {
    List<LicenseModel> lmList = new ArrayList<LicenseModel>();

    for (int i = 0; i < productElementList.getLength(); i++) {
        LicenseModel tempLM = new LicenseModel();
        Boolean isRestricted = true;

        Element productElement = (Element) productElementList.item(i);

        NamedNodeMap productElementAttributeMap = productElement.getAttributes();

        for (int j = 0; j < productElementAttributeMap.getLength(); j++) {
            Attr attrs = (Attr) productElementAttributeMap.item(j);

            if (attrs.getNodeName().equals("id")) {
                if (attrs.getNodeName() != null) {
                    tempLM.setId(attrs.getNodeValue());
                }
            }

        }

        Element titleElement = (Element) productElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "title").item(0);
        if (titleElement != null) {
            tempLM.setName(titleElement.getTextContent());
        }

        Element abstractElement = (Element) productElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "abstract").item(0);
        if (abstractElement != null) {
            tempLM.setDescription(abstractElement.getTextContent());
        }

        Element calculationElement = (Element) productElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "calculation").item(0);
        Element declarationListElement = (Element) calculationElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "declarationList").item(0);
        Element predefinedParametersElement = (Element) declarationListElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "predefinedParameters").item(0);

        NodeList predefinedParametersParameterElementList = predefinedParametersElement
                .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "parameter");

        for (int k = 0; k < predefinedParametersParameterElementList.getLength(); k++) {
            Element parameterElement = (Element) predefinedParametersParameterElementList.item(k);

            NamedNodeMap parameterElementAttributeMap = parameterElement.getAttributes();

            for (int l = 0; l < parameterElementAttributeMap.getLength(); l++) {
                Attr attrs = (Attr) parameterElementAttributeMap.item(l);

                if (attrs.getNodeName().equals("name")) {
                    if (attrs.getNodeName() != null) {
                        if (attrs.getNodeValue().equals("ALL_ROLES")) {
                            Element valueElement = (Element) parameterElement
                                    .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "value").item(0);

                            if (valueElement.getTextContent().equals("true")) {
                                isRestricted = false;
                            }
                        }
                    }
                }

                if (attrs.getNodeName().equals("name")) {
                    if (attrs.getNodeName() != null) {
                        if (attrs.getNodeValue().equals("ALLOWED_ROLES")) {
                            NodeList valueElementList = parameterElement
                                    .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "value");

                            for (int m = 0; m < valueElementList.getLength(); m++) {
                                tempLM.addRole(valueElementList.item(m).getTextContent());
                            }

                        }
                    }
                }

            }

        }

        tempLM.setRestricted(isRestricted);

        tempLM.setParams(createLicenseModelParamList(declarationListElement));

        lmList.add(tempLM);
    }

    return lmList;
}

From source file:bridge.toolkit.commands.S1000DConverter.java

/**
 * Iterate through the DOM tree/*from   w  w w.ja  v  a 2s  .co m*/
 * 
 * @param node
 * @param output
 * @throws IOException
 */
public static void writeNode(Node node, Writer output) throws IOException {

    int type = node.getNodeType();

    switch (type) {
    case Node.ATTRIBUTE_NODE:
        output.write(' ');
        output.write(node.getNodeName());
        output.write("=\"");
        writeXMLData(node.getNodeValue(), true, output);
        output.write('"');
        break;
    case Node.CDATA_SECTION_NODE:
    case Node.TEXT_NODE:
        writeXMLData(node.getNodeValue(), false, output);
        break;
    case Node.COMMENT_NODE:
        output.write("<!--");
        output.write(((Comment) node).getNodeValue());
        output.write("-->");
        break;
    case Node.DOCUMENT_FRAGMENT_NODE:
        writeNodes(node.getChildNodes(), output);
        break;
    case Node.DOCUMENT_NODE:
        writeNodes(node.getChildNodes(), output);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        break;
    case Node.ELEMENT_NODE: {
        NamedNodeMap atts = node.getAttributes();

        output.write('<');
        output.write(node.getNodeName());
        if (atts != null) {
            int length = atts.getLength();
            for (int i = 0; i < length; i++)
                writeNode(atts.item(i), output);
        }

        if (node.hasChildNodes()) {
            output.write('>');
            writeNodes(node.getChildNodes(), output);
            output.write("</");
            output.write(node.getNodeName());
            output.write('>');
        } else {
            output.write("/>");
        }
        break;
    }
    case Node.ENTITY_NODE:
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeNodes(node.getChildNodes(), output);
        break;
    case Node.NOTATION_NODE:
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        break;
    default:
        throw new Error("Unexpected DOM node type: " + type);
    }
}

From source file:DomUtils.java

/**
 * Rename element./*from  w w  w  .  j  av  a  2s  . c  om*/
 * @param element The element to be renamed.
 * @param replacementElement The tag name of the replacement element.
 * @param keepChildContent <code>true</code> if the target element's child content
 * is to be copied to the replacement element, false if not. Default <code>true</code>.
 * @param keepAttributes <code>true</code> if the target element's attributes
 * are to be copied to the replacement element, false if not. Default <code>true</code>.
 * @return The renamed element.
 */
public static Element renameElement(Element element, String replacementElement, boolean keepChildContent,
        boolean keepAttributes) {

    Element replacement = element.getOwnerDocument().createElement(replacementElement);
    if (keepChildContent) {
        DomUtils.copyChildNodes(element, replacement);
    }
    if (keepAttributes) {
        NamedNodeMap attributes = element.getAttributes();
        int attributeCount = attributes.getLength();

        for (int i = 0; i < attributeCount; i++) {
            Attr attribute = (Attr) attributes.item(i);
            replacement.setAttribute(attribute.getName(), attribute.getValue());
        }
    }
    DomUtils.replaceNode(replacement, element);

    return replacement;
}

From source file:com.centeractive.ws.builder.soap.SchemaUtils.java

/**
 * Returns a map mapping urls to corresponding XmlSchema XmlObjects for the
 * specified wsdlUrl//  w  w  w . ja v  a 2 s  . co  m
 */

public static void getSchemas(String wsdlUrl, Map<String, XmlObject> existing, SchemaLoader loader,
        String tns) {
    if (existing.containsKey(wsdlUrl)) {
        return;
    }

    // if( add )
    // existing.put( wsdlUrl, null );

    log.info("Getting schema " + wsdlUrl);

    ArrayList<?> errorList = new ArrayList<Object>();

    Map<String, XmlObject> result = new HashMap<String, XmlObject>();

    boolean common = false;

    try {
        XmlOptions options = new XmlOptions();
        options.setCompileNoValidation();
        options.setSaveUseOpenFrag();
        options.setErrorListener(errorList);
        options.setSaveSyntheticDocumentElement(new QName(Constants.XSD_NS, "schema"));

        XmlObject xmlObject = loader.loadXmlObject(wsdlUrl, options);
        if (xmlObject == null)
            throw new Exception("Failed to load schema from [" + wsdlUrl + "]");

        Document dom = (Document) xmlObject.getDomNode();
        Node domNode = dom.getDocumentElement();

        // is this an xml schema?
        if (domNode.getLocalName().equals("schema") && Constants.XSD_NS.equals(domNode.getNamespaceURI())) {
            // set targetNamespace (this happens if we are following an include
            // statement)
            if (tns != null) {
                Element elm = ((Element) domNode);
                if (!elm.hasAttribute("targetNamespace")) {
                    common = true;
                    elm.setAttribute("targetNamespace", tns);
                }

                // check for namespace prefix for targetNamespace
                NamedNodeMap attributes = elm.getAttributes();
                int c = 0;
                for (; c < attributes.getLength(); c++) {
                    Node item = attributes.item(c);
                    if (item.getNodeName().equals("xmlns"))
                        break;

                    if (item.getNodeValue().equals(tns) && item.getNodeName().startsWith("xmlns"))
                        break;
                }

                if (c == attributes.getLength())
                    elm.setAttribute("xmlns", tns);
            }

            if (common && !existing.containsKey(wsdlUrl + "@" + tns))
                result.put(wsdlUrl + "@" + tns, xmlObject);
            else
                result.put(wsdlUrl, xmlObject);
        } else {
            existing.put(wsdlUrl, null);

            XmlObject[] schemas = xmlObject
                    .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:schema");

            for (int i = 0; i < schemas.length; i++) {
                XmlCursor xmlCursor = schemas[i].newCursor();
                String xmlText = xmlCursor.getObject().xmlText(options);
                // schemas[i] = XmlObject.Factory.parse( xmlText, options );
                schemas[i] = XmlUtils.createXmlObject(xmlText, options);
                schemas[i].documentProperties().setSourceName(wsdlUrl);

                result.put(wsdlUrl + "@" + (i + 1), schemas[i]);
            }

            XmlObject[] wsdlImports = xmlObject
                    .selectPath("declare namespace s='" + Constants.WSDL11_NS + "' .//s:import/@location");
            for (int i = 0; i < wsdlImports.length; i++) {
                String location = ((SimpleValue) wsdlImports[i]).getStringValue();
                if (location != null) {
                    if (!location.startsWith("file:") && location.indexOf("://") == -1)
                        location = joinRelativeUrl(wsdlUrl, location);

                    getSchemas(location, existing, loader, null);
                }
            }

            XmlObject[] wadl10Imports = xmlObject.selectPath(
                    "declare namespace s='" + Constants.WADL10_NS + "' .//s:grammars/s:include/@href");
            for (int i = 0; i < wadl10Imports.length; i++) {
                String location = ((SimpleValue) wadl10Imports[i]).getStringValue();
                if (location != null) {
                    if (!location.startsWith("file:") && location.indexOf("://") == -1)
                        location = joinRelativeUrl(wsdlUrl, location);

                    getSchemas(location, existing, loader, null);
                }
            }

            XmlObject[] wadlImports = xmlObject.selectPath(
                    "declare namespace s='" + Constants.WADL11_NS + "' .//s:grammars/s:include/@href");
            for (int i = 0; i < wadlImports.length; i++) {
                String location = ((SimpleValue) wadlImports[i]).getStringValue();
                if (location != null) {
                    if (!location.startsWith("file:") && location.indexOf("://") == -1)
                        location = joinRelativeUrl(wsdlUrl, location);

                    getSchemas(location, existing, loader, null);
                }
            }

        }

        existing.putAll(result);

        XmlObject[] schemas = result.values().toArray(new XmlObject[result.size()]);

        for (int c = 0; c < schemas.length; c++) {
            xmlObject = schemas[c];

            XmlObject[] schemaImports = xmlObject
                    .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:import/@schemaLocation");
            for (int i = 0; i < schemaImports.length; i++) {
                String location = ((SimpleValue) schemaImports[i]).getStringValue();
                Element elm = ((Attr) schemaImports[i].getDomNode()).getOwnerElement();

                if (location != null && !defaultSchemas.containsKey(elm.getAttribute("namespace"))) {
                    if (!location.startsWith("file:") && location.indexOf("://") == -1)
                        location = joinRelativeUrl(wsdlUrl, location);

                    getSchemas(location, existing, loader, null);
                }
            }

            XmlObject[] schemaIncludes = xmlObject
                    .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:include/@schemaLocation");
            for (int i = 0; i < schemaIncludes.length; i++) {
                String location = ((SimpleValue) schemaIncludes[i]).getStringValue();
                if (location != null) {
                    String targetNS = getTargetNamespace(xmlObject);

                    if (!location.startsWith("file:") && location.indexOf("://") == -1)
                        location = joinRelativeUrl(wsdlUrl, location);

                    getSchemas(location, existing, loader, targetNS);
                }
            }
        }
    } catch (Exception e) {
        throw new SoapBuilderException(e);
    }
}

From source file:eu.europa.esig.dss.DSSXMLUtils.java

/**
 * If this method finds an attribute with names ID (case-insensitive) then it is returned. If there is more than one ID attributes then the first one is returned.
 *
 * @param element to be checked/*from   ww w .  ja va2  s  .  c o  m*/
 * @return the ID attribute value or null
 */
public static String getIDIdentifier(final Element element) {

    final NamedNodeMap attributes = element.getAttributes();
    for (int jj = 0; jj < attributes.getLength(); jj++) {

        final Node item = attributes.item(jj);
        final String localName = item.getNodeName();
        if (localName != null) {
            final String id = localName.toLowerCase();
            if (ID_ATTRIBUTE_NAME.equals(id)) {

                return item.getTextContent();
            }
        }
    }
    return null;
}