All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.milyn.cdres.trans.RenameElementTU Maven / Gradle / Ivy

The newest version!
/*
	Milyn - Copyright (C) 2006 - 2010

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License (version 2.1) as published by the Free Software 
	Foundation.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    
	See the GNU Lesser General Public License for more details:    
	http://www.gnu.org/licenses/lgpl.txt
*/

package org.milyn.cdres.trans;

import org.milyn.cdr.SmooksResourceConfiguration;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.cdr.annotation.ConfigParam;
import org.milyn.container.ExecutionContext;
import org.milyn.delivery.dom.DOMElementVisitor;
import org.milyn.xml.DomUtils;
import org.w3c.dom.Element;

/**
 * Renames/replaces an element in the document during the processing phase.
 *
 * The element is visited by this Processing Unit after it's child content
 * has been iterated over.
 *
 * See {@link DomUtils#renameElement(org.w3c.dom.Element, java.lang.String, boolean, boolean)}.
 * 
 * 

.cdrl Configuration

*
 * <smooks-resource	useragent="device/profile" selector="target-element-name" path="org.milyn.cdres.trans.RenameElementTU">
 * 
 * 	<!-- The name of the replacement element. -->
 * 	<param name="replacementElement">replacement-element-name</param>
 * 
 * 	<!-- (Optional) Copy target elements child content to the replacement 
 * 		element. Default is true. -->
 * 	<param name="keepChildContent">true/false</param>
 * 
 * 	<!-- (Optional) Copy target elements attributes to the replacement 
 * 		element. Default is true. -->
 * 	<param name="keepAttributes">true/false</param>
 * </smooks-resource>
* See {@link org.milyn.cdr.SmooksResourceConfiguration}. * * @author tfennelly */ public class RenameElementTU implements DOMElementVisitor { @ConfigParam private String replacementElement; @ConfigParam(use = ConfigParam.Use.OPTIONAL, defaultVal = "true") private boolean keepChildContent; @ConfigParam(use = ConfigParam.Use.OPTIONAL, defaultVal = "true") private boolean keepAttributes; public void visitBefore(Element element, ExecutionContext executionContext) { } public void visitAfter(Element element, ExecutionContext request) { DomUtils.renameElement(element, replacementElement, keepChildContent, keepAttributes); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy