Example usage for org.w3c.dom Node getOwnerDocument

List of usage examples for org.w3c.dom Node getOwnerDocument

Introduction

In this page you can find the example usage for org.w3c.dom Node getOwnerDocument.

Prototype

public Document getOwnerDocument();

Source Link

Document

The Document object associated with this node.

Usage

From source file:com.twinsoft.convertigo.engine.Context.java

public Node addTextNode(Node parentNode, String tagName, String text) {
    Document doc = parentNode.getOwnerDocument();
    Element newElement = doc.createElement(tagName);
    if (text != null) {
        Text textElement = doc.createTextNode(text);
        newElement.appendChild(textElement);
    }/*w  ww .j  a  va  2s.  c  o  m*/
    parentNode.appendChild(newElement);
    return newElement;
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

public static String nodeToString(Node node) {
    DOMImplementation impl = node.getOwnerDocument().getImplementation();
    DOMImplementationLS factory = (DOMImplementationLS) impl.getFeature("LS", "3.0");
    LSSerializer serializer = factory.createLSSerializer();
    return serializer.writeToString(node);
}

From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java

private void copyNode(Node sourceNode, Node destinationNode) {
    Document destinationDoc = destinationNode.getOwnerDocument();

    switch (sourceNode.getNodeType()) {
    case Node.TEXT_NODE:
        Text text = destinationDoc.createTextNode(sourceNode.getNodeValue());
        destinationNode.appendChild(text);
        break;/*from w w  w .  j  ava2  s  . c om*/
    case Node.ELEMENT_NODE:
        Element element = destinationDoc.createElement(sourceNode.getNodeName());
        destinationNode.appendChild(element);

        element.setTextContent(sourceNode.getNodeValue());

        // Copy attributes
        NamedNodeMap attributes = sourceNode.getAttributes();
        int nbAttributes = attributes.getLength();

        for (int i = 0; i < nbAttributes; i++) {
            Node attribute = attributes.item(i);
            element.setAttribute(attribute.getNodeName(), attribute.getNodeValue());
        }

        // Copy children nodes
        NodeList children = sourceNode.getChildNodes();
        int nbChildren = children.getLength();
        for (int i = 0; i < nbChildren; i++) {
            Node child = children.item(i);
            copyNode(child, element);
        }
    }
}

From source file:com.adaptris.util.XmlUtils.java

/**
 * Method which modifies the value of the Node returned by the XPath query
 * specified, relative to the provided parent node.
 *
 * @param xp the XPath which will return the Node to be updated
 * @param v the new value to set the node to
 * @param root the root node to apply the XPath to
 * @throws Exception on error.//from   w  w  w . jav  a2s.  com
 */
public void setNodeValue(String xp, String v, Node root) throws Exception {
    Node n = xpath.selectSingleNode(root, xp);

    if (n == null) {
        n = createNode(xp);
    }
    try {
        setNodeValue(v, n);
    } catch (NullPointerException ne) {
        // Node has no children!
        Document d = n.getOwnerDocument();
        Text t = d.createTextNode(v);
        n.appendChild(t);
    }

}

From source file:com.twinsoft.convertigo.beans.core.DatabaseObject.java

public static DatabaseObject read(Node node) throws EngineException {
    String objectClassName = "n/a";
    String childNodeName = "n/a";
    String propertyName = "n/a";
    String propertyValue = "n/a";
    DatabaseObject databaseObject = null;
    Element element = (Element) node;

    objectClassName = element.getAttribute("classname");

    // Migration to 4.x+ projects
    if (objectClassName.equals("com.twinsoft.convertigo.beans.core.ScreenClass")) {
        objectClassName = "com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass";
    }//from www. ja v  a2  s. c o m

    String version = element.getAttribute("version");
    if ("".equals(version)) {
        version = node.getOwnerDocument().getDocumentElement().getAttribute("beans");
        if (!"".equals(version)) {
            element.setAttribute("version", version);
        }
    }
    // Verifying product version
    if (VersionUtils.compareProductVersion(Version.productVersion, version) < 0) {
        String message = "Unable to create an object of product version superior to the current beans product version ("
                + com.twinsoft.convertigo.beans.Version.version + ").\n" + "Object class: " + objectClassName
                + "\n" + "Object version: " + version;
        EngineException ee = new EngineException(message);
        throw ee;
    }

    try {
        Engine.logBeans.trace("Creating object of class \"" + objectClassName + "\"");
        databaseObject = (DatabaseObject) Class.forName(objectClassName).newInstance();
    } catch (Exception e) {
        String s = node.getNodeName();// XMLUtils.prettyPrintDOM(node);
        String message = "Unable to create a new instance of the object from the serialized XML data.\n"
                + "Object class: '" + objectClassName + "'\n" + "Object version: " + version + "\n"
                + "XML data:\n" + s;
        EngineException ee = new EngineException(message, e);
        throw ee;
    }

    try {
        // Performs custom configuration before object de-serialization
        databaseObject.preconfigure(element);
    } catch (Exception e) {
        String s = XMLUtils.prettyPrintDOM(node);
        String message = "Unable to configure the object from serialized XML data before its creation.\n"
                + "Object class: '" + objectClassName + "'\n" + "XML data:\n" + s;
        EngineException ee = new EngineException(message, e);
        throw ee;
    }

    try {
        long priority = new Long(element.getAttribute("priority")).longValue();
        databaseObject.priority = priority;

        Class<? extends DatabaseObject> databaseObjectClass = databaseObject.getClass();
        BeanInfo bi = CachedIntrospector.getBeanInfo(databaseObjectClass);
        PropertyDescriptor[] pds = bi.getPropertyDescriptors();

        NodeList childNodes = element.getChildNodes();
        int len = childNodes.getLength();

        PropertyDescriptor pd;
        Object propertyObjectValue;
        Class<?> propertyType;
        NamedNodeMap childAttributes;
        boolean maskValue = false;

        for (int i = 0; i < len; i++) {
            Node childNode = childNodes.item(i);
            if (childNode.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }

            Element childElement = (Element) childNode;

            childNodeName = childNode.getNodeName();

            Engine.logBeans.trace("Analyzing node '" + childNodeName + "'");

            if (childNodeName.equalsIgnoreCase("property")) {
                childAttributes = childNode.getAttributes();
                propertyName = childAttributes.getNamedItem("name").getNodeValue();
                Engine.logBeans.trace("  name = '" + propertyName + "'");
                pd = findPropertyDescriptor(pds, propertyName);
                if (pd == null) {
                    Engine.logBeans.warn(
                            "Unable to find the definition of property \"" + propertyName + "\"; skipping.");
                    continue;
                }
                propertyType = pd.getPropertyType();
                propertyObjectValue = XMLUtils
                        .readObjectFromXml((Element) XMLUtils.findChildNode(childNode, Node.ELEMENT_NODE));

                // Hides value in log trace if needed
                if ("false".equals(childElement.getAttribute("traceable"))) {
                    maskValue = true;
                }
                Engine.logBeans.trace("  value='"
                        + (maskValue ? Visibility.maskValue(propertyObjectValue) : propertyObjectValue) + "'");

                // Decrypts value if needed
                try {
                    if ("true".equals(childElement.getAttribute("ciphered"))) {
                        propertyObjectValue = decryptPropertyValue(propertyObjectValue);
                    }
                } catch (Exception e) {
                }

                propertyObjectValue = databaseObject.compileProperty(propertyType, propertyName,
                        propertyObjectValue);

                if (Enum.class.isAssignableFrom(propertyType)) {
                    propertyObjectValue = EnumUtils.valueOf(propertyType, propertyObjectValue);
                }

                propertyValue = propertyObjectValue.toString();

                Method setter = pd.getWriteMethod();
                Engine.logBeans.trace("  setter='" + setter.getName() + "'");
                Engine.logBeans.trace("  param type='" + propertyObjectValue.getClass().getName() + "'");
                Engine.logBeans.trace("  expected type='" + propertyType.getName() + "'");
                try {
                    setter.invoke(databaseObject, new Object[] { propertyObjectValue });
                } catch (InvocationTargetException e) {
                    Throwable targetException = e.getTargetException();
                    Engine.logBeans.warn("Unable to set the property '" + propertyName + "' for the object '"
                            + databaseObject.getName() + "' (" + objectClassName + "): ["
                            + targetException.getClass().getName() + "] " + targetException.getMessage());
                }

                if (Boolean.TRUE.equals(pd.getValue("nillable"))) {
                    Node nodeNull = childAttributes.getNamedItem("isNull");
                    String valNull = (nodeNull == null) ? "false" : nodeNull.getNodeValue();
                    Engine.logBeans.trace("  treats as null='" + valNull + "'");
                    try {
                        Method method = databaseObject.getClass().getMethod("setNullProperty",
                                new Class[] { String.class, Boolean.class });
                        method.invoke(databaseObject, new Object[] { propertyName, Boolean.valueOf(valNull) });
                    } catch (Exception ex) {
                        Engine.logBeans.warn("Unable to set the 'isNull' attribute for property '"
                                + propertyName + "' of '" + databaseObject.getName() + "' object");
                    }
                }
            }
        }
    } catch (Exception e) {
        String message = "Unable to set the object properties from the serialized XML data.\n"
                + "Object class: '" + objectClassName + "'\n" + "XML analyzed node: " + childNodeName + "\n"
                + "Property name: " + propertyName + "\n" + "Property value: " + propertyValue;
        EngineException ee = new EngineException(message, e);
        throw ee;
    }

    try {
        // Performs custom configuration
        databaseObject.configure(element);
    } catch (Exception e) {
        String s = XMLUtils.prettyPrintDOM(node);
        String message = "Unable to configure the object from serialized XML data after its creation.\n"
                + "Object class: '" + objectClassName + "'\n" + "XML data:\n" + s;
        EngineException ee = new EngineException(message, e);
        throw ee;
    }

    return databaseObject;
}

From source file:de.betterform.xml.xforms.Container.java

public DocumentWrapper getDocumentWrapper(Node n) {
    final Document ownerDocument = n.getOwnerDocument();
    DocumentWrapper documentWrapper = fgDocumentWrapperCache.get(ownerDocument);
    if (documentWrapper == null) {
        documentWrapper = new DocumentWrapper(ownerDocument, getProcessor().getBaseURI(), getConfiguration());
        fgDocumentWrapperCache.put(ownerDocument, documentWrapper);
    }/*from  w  w  w. j a  va 2  s . c o  m*/

    return documentWrapper;
}

From source file:com.amalto.core.plugin.base.xslt.XSLTTransformerPluginBean.java

/**
 * @throws XtentisException/*from   w  ww . jav  a  2 s . c o  m*/
 * 
 * @ejb.interface-method view-type = "local"
 * @ejb.facade-method
 */
public void execute(TransformerPluginContext context) throws XtentisException {
    try {
        // fetch data from context
        Transformer transformer = (Transformer) context.get(TRANSFORMER);
        String outputMethod = (String) context.get(OUTPUT_METHOD);
        TypedContent xmlTC = (TypedContent) context.get(INPUT_XML);

        // get the charset
        String charset = Util.extractCharset(xmlTC.getContentType());

        // get the xml String
        String xml = new String(xmlTC.getContentBytes(), charset);

        // get the xml parameters
        TypedContent parametersTC = (TypedContent) context.get(INPUT_PARAMETERS);
        if (parametersTC != null) {
            String parametersCharset = Util.extractCharset(parametersTC.getContentType());

            byte[] parametersBytes = parametersTC.getContentBytes();
            if (parametersBytes != null) {
                String parameters = new String(parametersBytes, parametersCharset);

                Document parametersDoc = Util.parse(parameters);
                NodeList paramList = Util.getNodeList(parametersDoc.getDocumentElement(), "//Parameter"); //$NON-NLS-1$
                for (int i = 0; i < paramList.getLength(); i++) {
                    String paramName = Util.getFirstTextNode(paramList.item(i), "Name"); //$NON-NLS-1$
                    String paramValue = Util.getFirstTextNode(paramList.item(i), "Value"); //$NON-NLS-1$
                    if (paramValue == null)
                        paramValue = ""; //$NON-NLS-1$

                    if (paramName != null) {
                        transformer.setParameter(paramName, paramValue);
                    }
                }
            }
        }

        // FIXME: ARRRRGHHHHHH - How do you prevent the Transformer to process doctype instructions?

        // Sets the current time
        transformer.setParameter("TIMESTAMP", getTimestamp()); //$NON-NLS-1$
        transformer.setErrorListener(new ErrorListener() {

            public void error(TransformerException exception) throws TransformerException {
                transformatioError = exception.getMessage();
            }

            public void fatalError(TransformerException exception) throws TransformerException {
                transformatioError = exception.getMessage();
            }

            public void warning(TransformerException exception) throws TransformerException {
                transformationeWarning = exception.getMessage();

            }
        });
        transformatioError = null;
        transformationeWarning = null;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        if ("xml".equals(outputMethod) || "xhtml".equals(outputMethod)) { //$NON-NLS-1$ //$NON-NLS-2$
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document document = builder.newDocument();
            DOMResult domResult = new DOMResult(document);

            transformer.transform(new StreamSource(new StringReader(xml)), domResult);

            if (transformationeWarning != null) {
                String err = "Warning processing the XSLT: " + transformationeWarning; //$NON-NLS-1$
                LOG.warn(err);
            }
            if (transformatioError != null) {
                String err = "Error processing the XSLT: " + transformatioError; //$NON-NLS-1$
                LOG.error(err);
                throw new XtentisException(err);
            }
            Node rootNode = document.getDocumentElement();
            // process the cross-referencings
            NodeList xrefl = Util.getNodeList(rootNode.getOwnerDocument(), "//*[@xrefCluster]"); //$NON-NLS-1$
            int len = xrefl.getLength();
            for (int i = 0; i < len; i++) {
                Element xrefe = (Element) xrefl.item(i);
                xrefe = processMappings(xrefe);
            }
            TransformerFactory transFactory = new net.sf.saxon.TransformerFactoryImpl();
            Transformer serializer = transFactory.newTransformer();
            serializer.setOutputProperty(OutputKeys.METHOD, outputMethod);
            serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
            serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
            serializer.transform(new DOMSource(rootNode), new StreamResult(baos));
        } else {
            if (transformationeWarning != null) {
                String err = "Warning processing the XSLT: " + transformationeWarning; //$NON-NLS-1$
                LOG.warn(err);
            }
            if (transformatioError != null) {
                String err = "Error processing the XSLT: " + transformatioError; //$NON-NLS-1$
                LOG.error(err);
                throw new XtentisException(err);
            }
            // transform the item
            transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(baos));
        }
        // Call Back
        byte[] bytes = baos.toByteArray();
        if (LOG.isDebugEnabled()) {
            LOG.debug("execute() Inserting XSL Result in '" + OUTPUT_TEXT + "'\n" + new String(bytes, "utf-8")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        context.put(OUTPUT_TEXT,
                new TypedContent(bytes, ("xhtml".equals(outputMethod) ? "application/xhtml+xml" //$NON-NLS-1$//$NON-NLS-2$
                        : "text/" //$NON-NLS-1$
                                + outputMethod)
                        + "; charset=utf-8")); //$NON-NLS-1$
        context.getPluginCallBack().contentIsReady(context);
    } catch (Exception e) {
        String err = "Could not start the XSLT plugin"; //$NON-NLS-1$
        LOG.error(err, e);
        throw new XtentisException(err);
    }
}

From source file:com.twinsoft.convertigo.beans.core.Sequence.java

public static NodeList ouputDomView(NodeList nodeList, OutputFilter outputFilter) {
    if (nodeList != null) {
        int len = nodeList.getLength();
        if (len > 0) {
            Node node = nodeList.item(0);

            Document doc = node.getOwnerDocument();
            Element fake = doc.createElement("fake");
            Element root = (Element) doc.getDocumentElement().appendChild(fake);

            for (int i = 0; i < len; i++) {
                node = nodeList.item(i);
                root.appendChild(cloneNodeWithUserData(node, true));
            }//from www .j  a  va  2s  .  co  m

            buildOutputDom(root, outputFilter);

            doc.getDocumentElement().removeChild(fake);
            return fake.getChildNodes();
        }
        return nodeList;
    }
    return null;
}

From source file:com.vmware.identity.sts.ws.SignatureValidator.java

/**
 * Validates the request signature. If the signature is not valid the
 * relevant {@link WSFaultException} is thrown
 *
 * @param signatureNode/*  w  w w .ja v  a  2s. c  o m*/
 *           not null
 * @param signature
 *           not null
 */
private void validateSignature(Node signatureNode, Signature signature, Node timestampNode) {
    assert signatureNode != null;
    assert signature != null;
    assert timestampNode != null;

    XMLSignatureFactory fac = XMLSignatureFactory.getInstance();
    DOMValidateContext valContext = new DOMValidateContext(signature.getCertificate().getPublicKey(),
            signatureNode);
    try {
        XMLSignature xmlSignature = fac.unmarshalXMLSignature(valContext);
        if (!xmlSignature.validate(valContext)) {
            throw new WSFaultException(FaultKey.WSSE_FAILED_CHECK, "Signature is invalid.");
        }

        validateCanonicalizationMethod(xmlSignature);

        validateSignatureReferences(xmlSignature, valContext, signatureNode.getOwnerDocument(), timestampNode);

    } catch (MarshalException e) {
        throw new WSFaultException(FaultKey.WSSE_FAILED_CHECK, e);
    } catch (XMLSignatureException e) {
        throw new WSFaultException(FaultKey.WSSE_FAILED_CHECK, e);
    }
}

From source file:com.occamlab.te.parsers.ImageParser.java

private static void processBufferedImage(BufferedImage buffimage, String formatName, NodeList nodes)
        throws Exception {
    HashMap<Object, Object> bandMap = new HashMap<Object, Object>();

    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (node.getLocalName().equals("subimage")) {
                Element e = (Element) node;
                int x = Integer.parseInt(e.getAttribute("x"));
                int y = Integer.parseInt(e.getAttribute("y"));
                int w = Integer.parseInt(e.getAttribute("width"));
                int h = Integer.parseInt(e.getAttribute("height"));
                processBufferedImage(buffimage.getSubimage(x, y, w, h), formatName, e.getChildNodes());
            } else if (node.getLocalName().equals("checksum")) {
                CRC32 checksum = new CRC32();
                Raster raster = buffimage.getRaster();
                DataBufferByte buffer;
                if (node.getParentNode().getLocalName().equals("subimage")) {
                    WritableRaster outRaster = raster.createCompatibleWritableRaster();
                    buffimage.copyData(outRaster);
                    buffer = (DataBufferByte) outRaster.getDataBuffer();
                } else {
                    buffer = (DataBufferByte) raster.getDataBuffer();
                }/*from ww w .  j a  v a 2  s . c o m*/
                int numbanks = buffer.getNumBanks();
                for (int j = 0; j < numbanks; j++) {
                    checksum.update(buffer.getData(j));
                }
                Document doc = node.getOwnerDocument();
                node.appendChild(doc.createTextNode(Long.toString(checksum.getValue())));
            } else if (node.getLocalName().equals("count")) {
                String band = ((Element) node).getAttribute("bands");
                String sample = ((Element) node).getAttribute("sample");
                if (sample.equals("all")) {
                    bandMap.put(band, null);
                } else {
                    HashMap<Object, Object> sampleMap = (HashMap<Object, Object>) bandMap.get(band);
                    if (sampleMap == null) {
                        if (!bandMap.containsKey(band)) {
                            sampleMap = new HashMap<Object, Object>();
                            bandMap.put(band, sampleMap);
                        }
                    }
                    sampleMap.put(Integer.decode(sample), new Integer(0));
                }
            } else if (node.getLocalName().equals("transparentNodata")) { // 2011-08-24
                                                                          // PwD
                String transparentNodata = checkTransparentNodata(buffimage, node);
                node.setTextContent(transparentNodata);
            }
        }
    }

    Iterator bandIt = bandMap.keySet().iterator();
    while (bandIt.hasNext()) {
        String band_str = (String) bandIt.next();
        int band_indexes[];
        if (buffimage.getType() == BufferedImage.TYPE_BYTE_BINARY
                || buffimage.getType() == BufferedImage.TYPE_BYTE_GRAY) {
            band_indexes = new int[1];
            band_indexes[0] = 0;
        } else {
            band_indexes = new int[band_str.length()];
            for (int i = 0; i < band_str.length(); i++) {
                if (band_str.charAt(i) == 'A')
                    band_indexes[i] = 3;
                if (band_str.charAt(i) == 'B')
                    band_indexes[i] = 2;
                if (band_str.charAt(i) == 'G')
                    band_indexes[i] = 1;
                if (band_str.charAt(i) == 'R')
                    band_indexes[i] = 0;
            }
        }

        Raster raster = buffimage.getRaster();
        java.util.HashMap sampleMap = (java.util.HashMap) bandMap.get(band_str);
        boolean addall = (sampleMap == null);
        if (sampleMap == null) {
            sampleMap = new java.util.HashMap();
            bandMap.put(band_str, sampleMap);
        }

        int minx = raster.getMinX();
        int maxx = minx + raster.getWidth();
        int miny = raster.getMinY();
        int maxy = miny + raster.getHeight();
        int bands[][] = new int[band_indexes.length][raster.getWidth()];

        for (int y = miny; y < maxy; y++) {
            for (int i = 0; i < band_indexes.length; i++) {
                raster.getSamples(minx, y, maxx, 1, band_indexes[i], bands[i]);
            }
            for (int x = minx; x < maxx; x++) {
                int sample = 0;
                for (int i = 0; i < band_indexes.length; i++) {
                    sample |= bands[i][x] << ((band_indexes.length - i - 1) * 8);
                }

                Integer sampleObj = new Integer(sample);

                boolean add = addall;
                if (!addall) {
                    add = sampleMap.containsKey(sampleObj);
                }
                if (add) {
                    Integer count = (Integer) sampleMap.get(sampleObj);
                    if (count == null) {
                        count = new Integer(0);
                    }
                    count = new Integer(count.intValue() + 1);
                    sampleMap.put(sampleObj, count);
                }
            }
        }
    }

    Node node = nodes.item(0);
    while (node != null) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (node.getLocalName().equals("count")) {
                String band = ((Element) node).getAttribute("bands");
                String sample = ((Element) node).getAttribute("sample");
                HashMap sampleMap = (HashMap) bandMap.get(band);
                Document doc = node.getOwnerDocument();
                if (sample.equals("all")) {
                    Node parent = node.getParentNode();
                    Node prevSibling = node.getPreviousSibling();
                    Iterator sampleIt = sampleMap.keySet().iterator();
                    Element countnode = null;
                    int digits;
                    String prefix;
                    switch (buffimage.getType()) {
                    case BufferedImage.TYPE_BYTE_BINARY:
                        digits = 1;
                        prefix = "";
                        break;
                    case BufferedImage.TYPE_BYTE_GRAY:
                        digits = 2;
                        prefix = "0x";
                        break;
                    default:
                        prefix = "0x";
                        digits = band.length() * 2;
                    }
                    while (sampleIt.hasNext()) {
                        countnode = doc.createElementNS(node.getNamespaceURI(), "count");
                        Integer sampleInt = (Integer) sampleIt.next();
                        Integer count = (Integer) sampleMap.get(sampleInt);
                        if (band.length() > 0) {
                            countnode.setAttribute("bands", band);
                        }
                        countnode.setAttribute("sample", prefix + HexString(sampleInt.intValue(), digits));
                        Node textnode = doc.createTextNode(count.toString());
                        countnode.appendChild(textnode);
                        parent.insertBefore(countnode, node);
                        if (sampleIt.hasNext()) {
                            if (prevSibling != null && prevSibling.getNodeType() == Node.TEXT_NODE) {
                                parent.insertBefore(prevSibling.cloneNode(false), node);
                            }
                        }
                    }
                    parent.removeChild(node);
                    node = countnode;
                } else {
                    Integer count = (Integer) sampleMap.get(Integer.decode(sample));
                    if (count == null)
                        count = new Integer(0);
                    Node textnode = doc.createTextNode(count.toString());
                    node.appendChild(textnode);
                }
            }
        }
        node = node.getNextSibling();
    }
}