Example usage for org.xml.sax Attributes getURI

List of usage examples for org.xml.sax Attributes getURI

Introduction

In this page you can find the example usage for org.xml.sax Attributes getURI.

Prototype

public abstract String getURI(int index);

Source Link

Document

Look up an attribute's Namespace URI by index.

Usage

From source file:org.apache.cocoon.components.serializers.EncodingSerializer.java

/**
 * Receive notification of the beginning of an element.
 *//*from   w ww  .j  ava  2 s  . co  m*/
public void startElement(String nsuri, String local, String qual, Attributes attributes) throws SAXException {
    if (indentPerLevel > 0) {
        this.writeIndent(indentPerLevel * level);
        level++;
    }

    String name = this.namespaces.qualify(nsuri, local, qual);

    if (this.prolog) {
        this.body(nsuri, local, name);
        this.prolog = false;
    }

    String ns[][] = this.namespaces.commit();

    String at[][] = new String[attributes.getLength()][4];
    for (int x = 0; x < at.length; x++) {
        at[x][ATTRIBUTE_NSURI] = attributes.getURI(x);
        at[x][ATTRIBUTE_LOCAL] = attributes.getLocalName(x);
        at[x][ATTRIBUTE_QNAME] = namespaces.qualify(attributes.getURI(x), attributes.getLocalName(x),
                attributes.getQName(x));
        at[x][ATTRIBUTE_VALUE] = attributes.getValue(x);
    }

    this.startElementImpl(nsuri, local, name, ns, at);
}

From source file:org.apache.cocoon.transformation.LuceneIndexTransformer.java

public void endElement(String namespaceURI, String localName, String qName) throws SAXException {

    if (processing == STATE_QUERY) {
        if (LUCENE_URI.equals(namespaceURI) && LUCENE_QUERY_ELEMENT.equals(localName)) {
            // End query processing
            try {
                if (this.writer == null) {
                    openWriter();//  ww w  .  j av a 2  s  .c  o  m
                }
                this.writer.optimize();
                this.writer.close();
                this.writer = null;
            } catch (IOException e) {
                throw new SAXException(e);
            }
            // propagate the query element to the next stage in the pipeline
            super.endElement(namespaceURI, localName, qName);
            this.processing = STATE_GROUND;
        } else {
            throw new SAXException("</lucene:index> was expected!");
        }
    } else if (processing == STATE_DOCUMENT) {
        if (LUCENE_URI.equals(namespaceURI) && LUCENE_DOCUMENT_ELEMENT.equals(localName)) {
            // End document processing
            this.bodyDocument.add(Field.UnStored(LuceneXMLIndexer.BODY_FIELD, this.bodyText.toString()));
            this.bodyText = null;

            this.bodyDocument.add(Field.UnIndexed(LuceneXMLIndexer.URL_FIELD, this.bodyDocumentURL));
            // store: false, index: true, tokenize: false
            this.bodyDocument
                    .add(new Field(LuceneXMLIndexer.UID_FIELD, uid(this.bodyDocumentURL), false, true, false));
            try {
                reindexDocument();
            } catch (IOException e) {
                throw new SAXException(e);
            }
            this.bodyDocumentURL = null;

            // propagate the lucene:document element to the next stage in the pipeline
            long elapsedTime = System.currentTimeMillis() - this.documentStartTime;
            //documentAttributes = new AttributesImpl();
            this.documentAttributes.addAttribute("", LUCENE_ELAPSED_TIME_ATTRIBUTE,
                    LUCENE_ELAPSED_TIME_ATTRIBUTE, CDATA, String.valueOf(elapsedTime));
            super.startElement(namespaceURI, localName, qName, this.documentAttributes);
            super.endElement(namespaceURI, localName, qName);
            this.processing = STATE_QUERY;
        } else {
            // End element processing
            IndexHelperField tos = (IndexHelperField) elementStack.pop();
            StringBuffer text = tos.getText();

            Attributes atts = tos.getAttributes();
            boolean attributesToText = atts.getIndex(LUCENE_URI, LUCENE_ELEMENT_ATTR_TO_TEXT_ATTRIBUTE) != -1;
            for (int i = 0; i < atts.getLength(); i++) {
                // Ignore Lucene attributes
                if (LUCENE_URI.equals(atts.getURI(i)))
                    continue;

                String atts_lname = atts.getLocalName(i);
                String atts_value = atts.getValue(i);
                bodyDocument.add(Field.UnStored(localName + "@" + atts_lname, atts_value));
                if (attributesToText) {
                    text.append(atts_value);
                    text.append(' ');
                    bodyText.append(atts_value);
                    bodyText.append(' ');
                }
            }

            boolean store = atts.getIndex(LUCENE_URI, LUCENE_ELEMENT_ATTR_STORE_VALUE) != -1;
            if (text != null && text.length() > 0) {
                if (store) {
                    bodyDocument.add(Field.Text(localName, text.toString()));
                } else {
                    bodyDocument.add(Field.UnStored(localName, text.toString()));
                }
            }
        }
    } else {
        // All other tags
        super.endElement(namespaceURI, localName, qName);
    }
}

From source file:org.apache.cocoon.transformation.SparqlTransformer.java

public void startTransformingElement(String uri, String name, String raw, Attributes attr)
        throws ProcessingException, IOException, SAXException {
    if (name.equals(QUERY_ELEMENT)) {
        if (inQuery) {
            throw new ProcessingException("Nested SPARQL queries are not allowed.");
        }/*from  w  w  w . j a v  a2 s.  co  m*/
        inQuery = true;
        src = getAttribute(attr, SRC_ATTR, null);
        if (src == null)
            throw new ProcessingException(
                    "The " + SRC_ATTR + " attribute is mandatory for " + QUERY_ELEMENT + " elements.");
        method = getAttribute(attr, METHOD_ATTR, "GET");
        credentials = getAttribute(attr, CREDENTIALS_ATTR, "");
        contentType = getAttribute(attr, CONTENT_ATTR, "text");
        parameterName = getAttribute(attr, PARAMETER_NAME_ATTR, DEFAULT_QUERY_PARAM);
        parse = getAttribute(attr, PARSE_ATTR, "xml");
        showErrors = getAttribute(attr, SHOW_ERRORS_ATTR, "true").charAt(0) == 't';
        requestParameters = new SourceParameters();
        httpHeaders = new HashMap();
        // Process other attributes.
        for (int i = 0; i < attr.getLength(); ++i) {
            if (attr.getURI(i).equals(HTTP_NAMESPACE_URI)) {
                httpHeaders.put(attr.getLocalName(i), attr.getValue(i));
            } else if (attr.getURI(i).equals(SPARQL_NAMESPACE_URI)) {
                requestParameters.setParameter(attr.getLocalName(i), attr.getValue(i));
            }
        }
        if (contentType.equals("text")) {
            startTextRecording();
        } else if (contentType.equals("xml")) {
            startSerializedXMLRecording(null);
        } else {
            throw new ProcessingException("Unsupported query content type: " + contentType);
        }
    }
}

From source file:org.apache.fop.fo.PropertyList.java

/**
 * <p>Adds the attributes, passed in by the parser to the PropertyList.</p>
 * <p>Note that certain attributes are given priority in terms of order of
 * processing due to conversion dependencies, where the order is as follows:</p>
 * <ol>/*from   w ww.  ja  v  a2s  . co m*/
 * <li>writing-mode</li>
 * <li>column-number</li>
 * <li>number-columns-spanned</li>
 * <li>font</li>
 * <li>font-size</li>
 * <li><emph>all others in order of appearance</emph></li>
 * </ol>
 *
 * @param attributes Collection of attributes passed to us from the parser.
 * @throws ValidationException if there is an attribute that does not
 *          map to a property id (strict validation only)
 */
public void addAttributesToList(Attributes attributes) throws ValidationException {
    /*
     * Give writing-mode highest conversion priority.
     */
    addAttributeToList(attributes, "writing-mode");

    /*
     * If column-number/number-columns-spanned are specified, then we
     * need them before all others (possible from-table-column() on any
     * other property further in the list...
     */
    addAttributeToList(attributes, "column-number");
    addAttributeToList(attributes, "number-columns-spanned");

    /*
     * If font-size is set on this FO, must set it first, since
     * other attributes specified in terms of "ems" depend on it.
     */
    String checkValue = addAttributeToList(attributes, "font");
    if (checkValue == null || "".equals(checkValue)) {
        /*
         * font shorthand wasn't specified, so still need to process
         * explicit font-size
         */
        addAttributeToList(attributes, "font-size");
    }

    String attributeNS;
    String attributeName;
    String attributeValue;
    FopFactory factory = getFObj().getUserAgent().getFactory();
    for (int i = 0; i < attributes.getLength(); i++) {
        /* convert all attributes with the same namespace as the fo element
         * the "xml:lang" and "xml:base" properties are special cases */
        attributeNS = attributes.getURI(i);
        attributeName = attributes.getQName(i);
        attributeValue = attributes.getValue(i);
        if (attributeNS == null || attributeNS.length() == 0 || "xml:lang".equals(attributeName)
                || "xml:base".equals(attributeName)) {
            convertAttributeToProperty(attributes, attributeName, attributeValue);
        } else if (!factory.isNamespaceIgnored(attributeNS)) {
            ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(attributeNS);
            QName attr = new QName(attributeNS, attributeName);
            if (mapping != null) {
                if (mapping.isAttributeProperty(attr) && mapping.getStandardPrefix() != null) {
                    convertAttributeToProperty(attributes,
                            mapping.getStandardPrefix() + ":" + attr.getLocalName(), attributeValue);
                } else {
                    getFObj().addForeignAttribute(attr, attributeValue);
                }
            } else {
                handleInvalidProperty(attr);
            }
        }
    }
}

From source file:org.betaconceptframework.astroboa.engine.jcr.io.contenthandler.ImportContentHandler.java

private void importAttributes(Attributes atts) throws SAXException {

    if (atts != null && atts.getLength() > 0) {
        for (int i = 0; i < atts.getLength(); i++) {
            //Ignore attributes with specific namespaces
            String uri = atts.getURI(i);

            if (StringUtils.equals(uri, XMLConstants.XMLNS_ATTRIBUTE_NS_URI)
                    || StringUtils.equals(uri, XMLConstants.XML_NS_URI)
                    || StringUtils.equals(uri, XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)
                    || StringUtils.equals(uri, XMLConstants.W3C_XML_SCHEMA_NS_URI)
                    || StringUtils.equals(uri, XMLConstants.W3C_XPATH_DATATYPE_NS_URI)) {
                continue;
            }/*from  w  w  w.java2s .  c o  m*/

            addAttributeToImportedEntity(atts.getLocalName(i), atts.getValue(i));
        }
    }

}

From source file:org.eclipse.smila.connectivity.framework.crawler.web.parse.html.DOMBuilder.java

/**
 * Receive notification of the beginning of an element.
 * /*from   www  . j ava  2  s. c om*/
 * <p>
 * The Parser will invoke this method at the beginning of every element in the XML document; there will be a
 * corresponding endElement() event for every startElement() event (even when the element is empty). All of the
 * element's content will be reported, in order, before the corresponding endElement() event.
 * </p>
 * 
 * <p>
 * If the element name has a namespace prefix, the prefix will still be attached. Note that the attribute list
 * provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be
 * omitted.
 * </p>
 * 
 * @param ns
 *          The namespace of the node
 * @param localName
 *          The local part of the qualified name
 * @param name
 *          The element name.
 * @param atts
 *          The attributes attached to the element, if any.
 * 
 * @throws SAXException
 *           the SAX exception
 * 
 * @see #endElement
 * @see org.xml.sax.Attributes
 */
public void startElement(final String ns, final String localName, final String name, final Attributes atts)
        throws org.xml.sax.SAXException {

    Element elem;

    // Note that the namespace-aware call must be used to correctly
    // construct a Level 2 DOM, even for non-namespaced nodes.
    if ((null == ns) || (ns.length() == 0)) {
        elem = m_doc.createElementNS(null, name);
    } else {
        elem = m_doc.createElementNS(ns, name);
    }

    append(elem);

    try {
        final int nAtts = atts.getLength();

        if (0 != nAtts) {
            for (int i = 0; i < nAtts; i++) {

                // First handle a possible ID attribute
                if (atts.getType(i).equalsIgnoreCase("ID")) {
                    setIDAttribute(atts.getValue(i), elem);
                }

                String attrNS = atts.getURI(i);

                if ("".equals(attrNS)) {
                    attrNS = null; // DOM represents no-namespace as null
                }

                // System. out.println("attrNS: "+attrNS+", localName: "+atts.getQName(i)
                // +", qname: "+atts.getQName(i)+", value: "+atts.getValue(i));
                // Crimson won't let us set an xmlns: attribute on the DOM.
                final String attrQName = atts.getQName(i);

                // In SAX, xmlns: attributes have an empty namespace, while in DOM they should have the xmlns namespace
                if (attrQName.startsWith("xmlns:")) {
                    attrNS = "http://www.w3.org/2000/xmlns/";
                }

                // ALWAYS use the DOM Level 2 call!
                elem.setAttributeNS(attrNS, attrQName, atts.getValue(i));
            }
        }

        // append(elem);

        m_elemStack.push(elem);

        m_currentNode = elem;

        // append(elem);
    } catch (final java.lang.Exception de) {
        if (LOG.isErrorEnabled()) {
            LOG.error(de);
        }
        throw new org.xml.sax.SAXException(de);
    }

}

From source file:org.enhydra.shark.asap.util.BeanDeserializerShark.java

/**
 * Set the bean properties that correspond to element attributes.
 *
 * This method is invoked after startElement when the element requires
 * deserialization (i.e. the element is not an href and the value is not
 * nil.)//from   ww w  . j ava 2 s.c o  m
 * @param namespace is the namespace of the element
 * @param localName is the name of the element
 * @param prefix is the prefix of the element
 * @param attributes are the attributes on the element...used to get the
 *                   type
 * @param context is the DeserializationContext
 */
public void onStartElement(String namespace, String localName, String prefix, Attributes attributes,
        DeserializationContext context) throws SAXException {

    if (xmlType.toString().endsWith("GetPropertiesRs") || xmlType.toString().endsWith("SetPropertiesRs")) {
        //new Throwable("onStartElement namespace:"+namespace
        //    + "\nonStartElement localName:"+localName
        //    + "\nonStartElement prefix   :"+prefix).printStackTrace();
        String pp = xmlType.toString().substring(0, xmlType.toString().length() - "GetPropertiesRs".length());
        try {
            additional = new BeanDeserializerShark[3];
            additional[0] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.ObserverPropertiesGroup"),
                    new QName(pp + _addLocalNames[0]));
            additional[1] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.InstancePropertiesGroup"),
                    new QName(pp + _addLocalNames[1]));
            additional[2] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.FactoryPropertiesGroup"),
                    new QName(pp + _addLocalNames[2]));
        } catch (Throwable t) {
            t.printStackTrace();
            throw new SAXException(t.getMessage());
        }
        alreadyFailed = new boolean[3];
        int failures = 0;
        for (int n = 0; n < 3; ++n) {
            try {
                alreadyFailed[n] = false;
                additional[n].startElement(namespace, _addLocalNames[n], prefix, attributes, context);
            } catch (Throwable t) {
                t.printStackTrace();
                alreadyFailed[n] = true;
                ++failures;
            }
        }
        if (3 == failures)
            throw new SAXException(Messages.getMessage("cantCreateBean00", _addLocalNames[0], ""));
    }

    // The value should have been created or assigned already.
    // This code may no longer be needed.
    if (value == null) {
        // create a value
        try {
            value = javaType.newInstance();
        } catch (Exception e) {
            throw new SAXException(Messages.getMessage("cantCreateBean00", javaType.getName(), e.toString()));
        }
    }

    // If no type description meta data, there are no attributes,
    // so we are done.
    if (typeDesc == null)
        return;

    // loop through the attributes and set bean properties that
    // correspond to attributes
    for (int i = 0; i < attributes.getLength(); i++) {
        QName attrQName = new QName(attributes.getURI(i), attributes.getLocalName(i));
        String fieldName = typeDesc.getFieldNameForAttribute(attrQName);
        if (fieldName == null)
            continue;

        FieldDesc fieldDesc = typeDesc.getFieldByName(fieldName);

        // look for the attribute property
        BeanPropertyDescriptor bpd = (BeanPropertyDescriptor) propertyMap.get(fieldName);
        if (bpd != null) {
            if (!bpd.isWriteable() || bpd.isIndexed())
                continue;

            // Get the Deserializer for the attribute
            Deserializer dSer = getDeserializer(fieldDesc.getXmlType(), bpd.getType(), null, context);
            if (dSer == null) {
                dSer = context.getDeserializerForClass(bpd.getType());
            }
            if (dSer == null)
                throw new SAXException(Messages.getMessage("unregistered00", bpd.getType().toString()));

            if (!(dSer instanceof SimpleDeserializer))
                throw new SAXException(
                        Messages.getMessage("AttrNotSimpleType00", bpd.getName(), bpd.getType().toString()));

            // Success!  Create an object from the string and set
            // it in the bean
            try {
                dSer.onStartElement(namespace, localName, prefix, attributes, context);
                Object val = ((SimpleDeserializer) dSer).makeValue(attributes.getValue(i));
                bpd.set(value, val);
            } catch (Exception e) {
                throw new SAXException(e);
            }

        } // if
    } // attribute loop
}

From source file:org.enhydra.shark.wfxml.util.BeanDeserializerShark.java

/**
 * Set the bean properties that correspond to element attributes.
 *
 * This method is invoked after startElement when the element requires
 * deserialization (i.e. the element is not an href and the value is not
 * nil.)/*from   ww  w.  jav  a2  s  .  com*/
 * @param namespace is the namespace of the element
 * @param localName is the name of the element
 * @param prefix is the prefix of the element
 * @param attributes are the attributes on the element...used to get the
 *                   type
 * @param context is the DeserializationContext
 */
public void onStartElement(String namespace, String localName, String prefix, Attributes attributes,
        DeserializationContext context) throws SAXException {

    if (xmlType.toString().endsWith("GetPropertiesRs") || xmlType.toString().endsWith("SetPropertiesRs")) {
        //new Throwable("onStartElement namespace:"+namespace
        //    + "\nonStartElement localName:"+localName
        //    + "\nonStartElement prefix   :"+prefix).printStackTrace();
        String pp = xmlType.toString().substring(0, xmlType.toString().length() - "GetPropertiesRs".length());
        try {
            additional = new BeanDeserializerShark[4];
            additional[0] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.ObserverPropertiesGroup"),
                    new QName(pp + _addLocalNames[0]));
            additional[1] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.InstancePropertiesGroup"),
                    new QName(pp + _addLocalNames[1]));
            additional[2] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.asap.types.FactoryPropertiesGroup"),
                    new QName(pp + _addLocalNames[2]));
            additional[3] = new BeanDeserializerShark(
                    Class.forName("org.enhydra.shark.wfxml.types.RegistryPropertiesGroup"),
                    new QName(pp + _addLocalNames[3]));
        } catch (Throwable t) {
            t.printStackTrace();
            throw new SAXException(t.getMessage());
        }
        alreadyFailed = new boolean[additional.length];
        int failures = 0;
        for (int n = 0; n < additional.length; ++n) {
            try {
                alreadyFailed[n] = false;
                additional[n].startElement(namespace, _addLocalNames[n], prefix, attributes, context);
            } catch (Throwable t) {
                t.printStackTrace();
                alreadyFailed[n] = true;
                ++failures;
            }
        }
        if (additional.length == failures)
            throw new SAXException(Messages.getMessage("cantCreateBean00", _addLocalNames[0], ""));
    }

    // The value should have been created or assigned already.
    // This code may no longer be needed.
    if (value == null) {
        // create a value
        try {
            value = javaType.newInstance();
        } catch (Exception e) {
            throw new SAXException(Messages.getMessage("cantCreateBean00", javaType.getName(), e.toString()));
        }
    }

    // If no type description meta data, there are no attributes,
    // so we are done.
    if (typeDesc == null)
        return;

    // loop through the attributes and set bean properties that
    // correspond to attributes
    for (int i = 0; i < attributes.getLength(); i++) {
        QName attrQName = new QName(attributes.getURI(i), attributes.getLocalName(i));
        String fieldName = typeDesc.getFieldNameForAttribute(attrQName);
        if (fieldName == null)
            continue;

        FieldDesc fieldDesc = typeDesc.getFieldByName(fieldName);

        // look for the attribute property
        BeanPropertyDescriptor bpd = (BeanPropertyDescriptor) propertyMap.get(fieldName);
        if (bpd != null) {
            if (!bpd.isWriteable() || bpd.isIndexed())
                continue;

            // Get the Deserializer for the attribute
            Deserializer dSer = getDeserializer(fieldDesc.getXmlType(), bpd.getType(), null, context);
            if (dSer == null) {
                dSer = context.getDeserializerForClass(bpd.getType());
            }
            if (dSer == null)
                throw new SAXException(Messages.getMessage("unregistered00", bpd.getType().toString()));

            if (!(dSer instanceof SimpleDeserializer))
                throw new SAXException(
                        Messages.getMessage("AttrNotSimpleType00", bpd.getName(), bpd.getType().toString()));

            // Success!  Create an object from the string and set
            // it in the bean
            try {
                dSer.onStartElement(namespace, localName, prefix, attributes, context);
                Object val = ((SimpleDeserializer) dSer).makeValue(attributes.getValue(i));
                bpd.set(value, val);
            } catch (Exception e) {
                throw new SAXException(e);
            }

        } // if
    } // attribute loop
}

From source file:org.exolab.castor.xml.parsing.AttributeSetBuilder.java

/**
 * Processes the attributes and XML name space declarations found in the given SAX Attributes. The
 * global {@link AttributeSet} is cleared and updated with the attributes. XML name space
 * declarations are added to the set of name spaces in scope.
 * /*from   www  .jav a 2 s  . c  o  m*/
 * @param atts the Attributes to process (can be null).
 **/
private AttributeSet processAttributes(Attributes atts, AttributeSetImpl attributeSet) {
    // -- process attributes

    if (atts == null || atts.getLength() == 0) {
        return attributeSet;
    }

    boolean hasQNameAtts = false;
    // -- look for any potential namespace declarations
    // -- in case namespace processing was disable
    // -- on the parser
    for (int i = 0; i < atts.getLength(); i++) {
        String attName = atts.getQName(i);
        if (StringUtils.isNotEmpty(attName)) {
            if (!attName.equals(XMLNS) && !attName.startsWith(XMLNS_PREFIX)) {
                // -- check for prefix
                if (attName.indexOf(':') < 0) {
                    attributeSet.setAttribute(attName, atts.getValue(i), atts.getURI(i));
                } else
                    hasQNameAtts = true;
            }
        } else {
            // -- if attName is null or empty, just process as a normal
            // -- attribute
            attName = atts.getLocalName(i);
            if (!XMLNS.equals(attName)) {
                attributeSet.setAttribute(attName, atts.getValue(i), atts.getURI(i));
            }
        }
    }

    // return if there are no qualified name attributes
    if (!hasQNameAtts) {
        return attributeSet;
    }
    // -- if we found any qName-only atts, process those
    for (int i = 0; i < atts.getLength(); i++) {
        String attName = atts.getQName(i);
        if (StringUtils.isNotEmpty(attName)) {
            // -- process any non-namespace qName atts
            if ((!attName.equals(XMLNS)) && (!attName.startsWith(XMLNS_PREFIX))) {
                int idx = attName.indexOf(':');
                if (idx >= 0) {
                    String prefix = attName.substring(0, idx);
                    attName = attName.substring(idx + 1);
                    String nsURI = atts.getURI(i);
                    if (StringUtils.isEmpty(nsURI)) {
                        nsURI = _namespaceHandling.getNamespaceURI(prefix);
                    }
                    attributeSet.setAttribute(attName, atts.getValue(i), nsURI);
                }
            }
        }
        // -- else skip already processed in previous loop
    }
    return attributeSet;
}

From source file:org.jahia.services.importexport.DocumentViewImportHandler.java

private void setAttributes(JCRNodeWrapper child, Attributes atts) throws RepositoryException {
    String lang = null;/* ww  w . ja  v  a2  s .c om*/
    if (child.getPrimaryNodeTypeName().equals(Constants.JAHIANT_TRANSLATION)) {
        lang = atts.getValue(Constants.JCR_LANGUAGE);
        child.setProperty(Constants.JCR_LANGUAGE, lang);
    }

    for (int i = 0; i < atts.getLength(); i++) {
        if (atts.getURI(i).equals("http://www.w3.org/2000/xmlns/")) {
            continue;
        }

        String attrName = ISO9075.decode(atts.getQName(i));
        String attrValue = atts.getValue(i);

        boolean processed = false;
        for (AttributeProcessor processor : attributeProcessors) {
            if (processor.process(child, attrName, attrValue)) {
                processed = true;
                break;
            }
        }
        if (processed) {
            continue;
        }

        for (String placeHolder : placeHoldersMap.keySet()) {
            if (attrValue.contains(placeHolder)) {
                attrValue = attrValue.replace(placeHolder, placeHoldersMap.get(placeHolder));
            }
        }

        if (propertiesToSkip.contains(attrName)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping property {}", attrName);
            }
        } else {
            for (Map.Entry<Pattern, String> entry : replacements.entrySet()) {
                attrValue = entry.getKey().matcher(attrValue).replaceAll(entry.getValue());
            }

            if (attrName.equals("j:privileges") && child.isNodeType("jnt:ace")) {
                attrName = "j:roles";
                attrValue = mapAclAttributes(child, attrValue);
                if (StringUtils.isEmpty(attrValue)) {
                    // Value is mandatory, set a fake role to allow import to continue
                    attrValue = "dummy-role";
                }
            }

            if ((attrName.equals(Constants.JCR_TITLE) || attrName.equals("jcr:description"))
                    && !child.isNodeType(Constants.MIX_TITLE)) {
                child.addMixin(Constants.MIX_TITLE);
            } else if (attrName.equals("j:defaultCategory")
                    && !child.isNodeType(Constants.JAHIAMIX_CATEGORIZED)) {
                child.addMixin(Constants.JAHIAMIX_CATEGORIZED);
            }
            ExtendedPropertyDefinition propDef;
            propDef = child.getApplicablePropertyDefinition(attrName);
            if (propDef == null) {
                logger.error("Couldn't find definition for property " + attrName + " in "
                        + child.getPrimaryNodeTypeName() + getLocation());
                continue;
            }

            if (propDef.getRequiredType() == PropertyType.UNDEFINED) {
                // avoid illegal type 0
                //...getValueFactory().createValue(value, 0) throw a illegal type 0 exception
                logger.error("Couldn't resolve property type for property " + attrName + " in "
                        + child.getPrimaryNodeTypeName() + getLocation());
                continue;
            }

            if (propDef.getRequiredType() == PropertyType.REFERENCE
                    || propDef.getRequiredType() == ExtendedPropertyType.WEAKREFERENCE) {
                if (attrValue.length() > 0) {
                    String[] values = propDef.isMultiple() ? Patterns.SPACE.split(attrValue)
                            : new String[] { attrValue };
                    for (String value : values) {
                        value = JCRMultipleValueUtils.decode(value);
                        if (!StringUtils.isEmpty(value)) {
                            value = getReferenceValue(value);
                            if (attrName.equals("j:defaultCategory") && value.startsWith("/root")) {
                                // Map categories from legacy imports
                                value = JCRContentUtils.getSystemSitePath() + "/categories"
                                        + StringUtils.substringAfter(value, "/root");
                            }
                            if (!references.containsKey(value)) {
                                references.put(value, new ArrayList<String>());
                            }
                            references.get(value).add(child.getIdentifier() + "/" + attrName);
                        }
                    }
                }
            } else {
                if (propDef.isMultiple()) {
                    String[] s = "".equals(attrValue) ? new String[0] : Patterns.SPACE.split(attrValue);
                    List<Value> oldvalues = new ArrayList<Value>();

                    if (child.getRealNode().hasProperty(attrName)) {
                        Value[] oldValues = child.getRealNode().getProperty(attrName).getValues();
                        for (Value oldValue : oldValues) {
                            oldvalues.add(oldValue);
                        }
                    }

                    if (replaceMultipleValues) {
                        List<Value> values = new ArrayList<Value>();
                        for (int j = 0; j < s.length; j++) {
                            values.add(child.getRealNode().getSession().getValueFactory().createValue(
                                    JCRMultipleValueUtils.decode(s[j]), propDef.getRequiredType()));
                        }
                        if (!values.equals(oldvalues)) {
                            child.getRealNode().setProperty(attrName, values.toArray(new Value[values.size()]));
                        }
                    } else {
                        List<Value> values = new ArrayList<Value>(oldvalues);
                        for (int j = 0; j < s.length; j++) {
                            final Value value = child.getRealNode().getSession().getValueFactory()
                                    .createValue(JCRMultipleValueUtils.decode(s[j]), propDef.getRequiredType());
                            if (!oldvalues.contains(value)) {
                                values.add(value);
                            }
                        }
                        try {
                            if (!values.equals(oldvalues)) {
                                child.getRealNode().setProperty(attrName,
                                        values.toArray(new Value[values.size()]));
                            }
                        } catch (RepositoryException e) {
                            logger.error(e.getMessage(), e); //To change body of catch statement use File | Settings | File Templates.
                        }
                    }
                } else {
                    if (!child.getRealNode().hasProperty(attrName)
                            || !child.getRealNode().getProperty(attrName).getString().equals(attrValue)) {
                        child.getRealNode().setProperty(attrName, attrValue, propDef.getRequiredType());
                    }
                }
            }
        }
    }
}