public void copyLocale(Locale source, Locale destination, Set<String> elements) throws CmsXmlException {

        if (!hasLocale(source)) {
            throw new CmsXmlException(
                Messages.get().container(org.opencms.xml.Messages.ERR_LOCALE_NOT_AVAILABLE_1, source));
        }
        if (hasLocale(destination)) {
            throw new CmsXmlException(
                Messages.get().container(org.opencms.xml.Messages.ERR_LOCALE_ALREADY_EXISTS_1, destination));
        }

        Element sourceElement = null;
        Element rootNode = m_document.getRootElement();
        Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(rootNode);
        String localeStr = source.toString();
        while (i.hasNext()) {
            Element element = i.next();
            String language = element.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_LANGUAGE, null);
            if ((language != null) && (localeStr.equals(language))) {
                // detach node with the locale
                sourceElement = createDeepElementCopy(element, elements);
                // there can be only one node for the locale
                break;
            }
        }

        if (sourceElement == null) {
            // should not happen since this was checked already, just to make sure...
            throw new CmsXmlException(
                Messages.get().container(org.opencms.xml.Messages.ERR_LOCALE_NOT_AVAILABLE_1, source));
        }

        // switch locale value in attribute of copied node
        sourceElement.addAttribute(CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_LANGUAGE, destination.toString());
        // attach the copied node to the root node
        rootNode.add(sourceElement);

        // re-initialize the document bookmarks
        initDocument(m_document, m_encoding, getContentDefinition());
    }
public void copyLocale ( Locale source , Locale destination , Set < String > elements ) throws CmsXmlException { if ( ! hasLocale ( source ) ) { throw new CmsXmlException ( Messages . get ( ) . container ( org . opencms . xml . Messages . ERR_LOCALE_NOT_AVAILABLE_1 , source ) ) ; } if ( hasLocale ( destination ) ) { throw new CmsXmlException ( Messages . get ( ) . container ( org . opencms . xml . Messages . ERR_LOCALE_ALREADY_EXISTS_1 , destination ) ) ; } Element sourceElement = null ; Element rootNode = m_document . getRootElement ( ) ; Iterator < Element > i = CmsXmlGenericWrapper . elementIterator ( rootNode ) ; String localeStr = source . toString ( ) ; while ( i . hasNext ( ) ) { Element element = i . next ( ) ; String language = element . attributeValue ( CmsXmlContentDefinition . XSD_ATTRIBUTE_VALUE_LANGUAGE , null ) ; if ( ( language != null ) && ( localeStr . equals ( language ) ) ) { sourceElement = createDeepElementCopy ( element , elements ) ; break ; } } if ( sourceElement == null ) { throw new CmsXmlException ( Messages . get ( ) . container ( org . opencms . xml . Messages . ERR_LOCALE_NOT_AVAILABLE_1 , source ) ) ; } sourceElement . addAttribute ( CmsXmlContentDefinition . XSD_ATTRIBUTE_VALUE_LANGUAGE , destination . toString ( ) ) ; rootNode . add ( sourceElement ) ; initDocument ( m_document , m_encoding , getContentDefinition ( ) ) ; }
Copies the content of the given source locale to the given destination locale in this XML document.<p>

@param source the source locale
@param destination the destination loacle
@param elements the set of elements to copy
@throws CmsXmlException if something goes wrong