com.github.simy4.xpath.dom.spi.DomNavigatorSpi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xpath-to-xml-dom Show documentation
Show all versions of xpath-to-xml-dom Show documentation
Convenient utility to build XML models by evaluating XPath expressions
package com.github.simy4.xpath.dom.spi;
import com.github.simy4.xpath.XmlBuilderException;
import com.github.simy4.xpath.dom.navigator.DomNavigator;
import com.github.simy4.xpath.dom.navigator.DomNode;
import com.github.simy4.xpath.effects.Effect;
import com.github.simy4.xpath.navigator.Navigator;
import com.github.simy4.xpath.spi.NavigatorSpi;
import org.w3c.dom.Node;
/**
* Standard DOM model navigator extension SPI.
*/
public class DomNavigatorSpi implements NavigatorSpi {
@Override
public boolean canHandle(Object o) {
return o instanceof Node;
}
@Override
public T process(T xml, Iterable effects) throws XmlBuilderException {
if (!canHandle(xml)) {
throw new IllegalArgumentException("XML model is not supported");
}
final Node xmlNode = (Node) xml;
final DomNode node = new DomNode(xmlNode);
final Navigator navigator = new DomNavigator(xmlNode);
for (Effect effect : effects) {
effect.perform(navigator, node);
}
return xml;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy