private void addEntityAttributes(
        CmsObject cms,
        CmsXmlContent content,
        String parentPath,
        CmsEntity entity,
        Locale contentLocale,
        Set<String> fieldsSet) {

        for (CmsEntityAttribute attribute : entity.getAttributes()) {
            if (!isSettingsAttribute(attribute.getAttributeName())) {
                if (CmsType.CHOICE_ATTRIBUTE_NAME.equals(attribute.getAttributeName())) {
                    List<CmsEntity> choiceEntities = attribute.getComplexValues();
                    for (int i = 0; i < choiceEntities.size(); i++) {
                        List<CmsEntityAttribute> choiceAttributes = choiceEntities.get(i).getAttributes();
                        // each choice entity may only have a single attribute with a single value
                        assert (choiceAttributes.size() == 1)
                            && choiceAttributes.get(
                                0).isSingleValue() : "each choice entity may only have a single attribute with a single value";
                        CmsEntityAttribute choiceAttribute = choiceAttributes.get(0);
                        String elementPath = parentPath + getElementName(choiceAttribute.getAttributeName());
                        if (choiceAttribute.isSimpleValue()) {
                            String value = choiceAttribute.getSimpleValue();
                            I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i);
                            if (field == null) {
                                field = content.addValue(cms, elementPath, contentLocale, i);
                            }
                            field.setStringValue(cms, value);
                            fieldsSet.add(field.getPath());
                        } else {
                            CmsEntity child = choiceAttribute.getComplexValue();
                            I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i);
                            if (field == null) {
                                field = content.addValue(cms, elementPath, contentLocale, i);
                            }
                            addEntityAttributes(cms, content, field.getPath() + "/", child, contentLocale, fieldsSet);
                        }
                    }
                } else {
                    String elementPath = parentPath + getElementName(attribute.getAttributeName());
                    if (attribute.isSimpleValue()) {
                        List<String> values = attribute.getSimpleValues();
                        for (int i = 0; i < values.size(); i++) {
                            String value = values.get(i);
                            I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i);
                            if (field == null) {
                                field = content.addValue(cms, elementPath, contentLocale, i);
                            }
                            field.setStringValue(cms, value);
                            fieldsSet.add(field.getPath());
                        }
                    } else {
                        List<CmsEntity> entities = attribute.getComplexValues();
                        for (int i = 0; i < entities.size(); i++) {
                            CmsEntity child = entities.get(i);
                            I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i);
                            if (field == null) {
                                field = content.addValue(cms, elementPath, contentLocale, i);
                            }
                            addEntityAttributes(cms, content, field.getPath() + "/", child, contentLocale, fieldsSet);
                        }
                    }
                }
            }
        }
    }
private void addEntityAttributes ( CmsObject cms , CmsXmlContent content , String parentPath , CmsEntity entity , Locale contentLocale , Set < String > fieldsSet ) { for ( CmsEntityAttribute attribute : entity . getAttributes ( ) ) { if ( ! isSettingsAttribute ( attribute . getAttributeName ( ) ) ) { if ( CmsType . CHOICE_ATTRIBUTE_NAME . equals ( attribute . getAttributeName ( ) ) ) { List < CmsEntity > choiceEntities = attribute . getComplexValues ( ) ; for ( int i = 0 ; i < choiceEntities . size ( ) ; i ++ ) { List < CmsEntityAttribute > choiceAttributes = choiceEntities . get ( i ) . getAttributes ( ) ; assert ( choiceAttributes . size ( ) == 1 ) && choiceAttributes . get ( 0 ) . isSingleValue ( ) : "each choice entity may only have a single attribute with a single value" ; CmsEntityAttribute choiceAttribute = choiceAttributes . get ( 0 ) ; String elementPath = parentPath + getElementName ( choiceAttribute . getAttributeName ( ) ) ; if ( choiceAttribute . isSimpleValue ( ) ) { String value = choiceAttribute . getSimpleValue ( ) ; I_CmsXmlContentValue field = content . getValue ( elementPath , contentLocale , i ) ; if ( field == null ) { field = content . addValue ( cms , elementPath , contentLocale , i ) ; } field . setStringValue ( cms , value ) ; fieldsSet . add ( field . getPath ( ) ) ; } else { CmsEntity child = choiceAttribute . getComplexValue ( ) ; I_CmsXmlContentValue field = content . getValue ( elementPath , contentLocale , i ) ; if ( field == null ) { field = content . addValue ( cms , elementPath , contentLocale , i ) ; } addEntityAttributes ( cms , content , field . getPath ( ) + "/" , child , contentLocale , fieldsSet ) ; } } } else { String elementPath = parentPath + getElementName ( attribute . getAttributeName ( ) ) ; if ( attribute . isSimpleValue ( ) ) { List < String > values = attribute . getSimpleValues ( ) ; for ( int i = 0 ; i < values . size ( ) ; i ++ ) { String value = values . get ( i ) ; I_CmsXmlContentValue field = content . getValue ( elementPath , contentLocale , i ) ; if ( field == null ) { field = content . addValue ( cms , elementPath , contentLocale , i ) ; } field . setStringValue ( cms , value ) ; fieldsSet . add ( field . getPath ( ) ) ; } } else { List < CmsEntity > entities = attribute . getComplexValues ( ) ; for ( int i = 0 ; i < entities . size ( ) ; i ++ ) { CmsEntity child = entities . get ( i ) ; I_CmsXmlContentValue field = content . getValue ( elementPath , contentLocale , i ) ; if ( field == null ) { field = content . addValue ( cms , elementPath , contentLocale , i ) ; } addEntityAttributes ( cms , content , field . getPath ( ) + "/" , child , contentLocale , fieldsSet ) ; } } } } } }
Adds the attribute values of the entity to the given XML content.<p>

@param cms the current cms context
@param content the XML content
@param parentPath the parent path
@param entity the entity
@param contentLocale the content locale
@param fieldsSet set to store which fields were set in the XML content