本文整理汇总了Java中org.w3c.dom.Element.cloneNode方法的典型用法代码示例。如果您正苦于以下问题:Java Element.cloneNode方法的具体用法?Java Element.cloneNode怎么用?Java Element.cloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.cloneNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixupAttrs
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Element fixupAttrs(Element root) { // #140905
// #6529766/#6531160: some versions of JAXP reject attributes set using setAttribute
// (rather than setAttributeNS) even though the schema calls for no-NS attrs!
// JDK 5 is fine; JDK 6 broken; JDK 6u2+ fixed
// #146081: xml:base attributes mess up validation too.
Element copy = (Element) root.cloneNode(true);
fixupAttrsSingle(copy);
NodeList nl = copy.getElementsByTagName("*"); // NOI18N
for (int i = 0; i < nl.getLength(); i++) {
fixupAttrsSingle((Element) nl.item(i));
}
return copy;
}
示例2: extendXMLMap
import org.w3c.dom.Element; //导入方法依赖的package包/类
public Element extendXMLMap(Element elt) {
if (elt != null) {
NodeList childs = elt.getChildNodes();
int len = childs.getLength();
if (len > 0) {
for (int i=0; i<len; i++) {
Node children = childs.item(i);
if (children.getNodeType() == Node.ELEMENT_NODE)
extendXMLMap((Element)children);
}
}
String sOccurs = elt.getAttribute("occurs");
if ((sOccurs != null) && (!sOccurs.equalsIgnoreCase(""))) {
String aOccurs[] = sOccurs.split(":");
int j = Integer.parseInt(aOccurs[0],10);
if (aOccurs.length>1)
j = Integer.parseInt(aOccurs[1],10);
int count = 1;
elt.setAttribute("occurence",""+count);
while (count++ < j) {
Element clone = (Element)elt.cloneNode(true);
clone.setAttribute("occurence",""+count);
elt.getParentNode().appendChild(clone);
}
}
}
return elt;
}
示例3: expandXMLMap
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void expandXMLMap(Element elt) {
if (elt != null) {
NodeList children = elt.getChildNodes();
Node next = elt.getNextSibling();
int len = children.getLength();
if (len > 0) {
Node child = children.item(0);
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE)
expandXMLMap((Element)child);
child = child.getNextSibling();
}
}
String sOccurs = elt.getAttribute("occurs");
if ((sOccurs != null) && (!sOccurs.equalsIgnoreCase(""))) {
String aOccurs[] = sOccurs.split(":");
int count = 1;
int j = Integer.parseInt(aOccurs[0],10);
if (aOccurs.length>1)
j = Integer.parseInt(aOccurs[1],10);
while (count++ < j) {
elt.setAttribute("occurs","");
Element clone = (Element)elt.cloneNode(true);
clone.setAttribute("occurence",""+count);
expandXMLElement(elt,clone,count);
if (next != null)
elt.getParentNode().insertBefore(clone,next);
else
elt.getParentNode().appendChild(clone);
}
//elt.setAttribute("occurs",sOccurs);
}
}
}
示例4: getRegion
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Element[] getRegion(Element[][][] regions, float lat, float lon, Element parent, Document doc) {
int x = (int) Math.floor((lon + 180) / LON_PARTITION_N);
int y = (int) Math.floor((lat + 90) / LAT_PARTITION_N);
if (x >= regions.length) x = 0;
if (y >= regions[0].length) y = regions[0].length - 1;
if (x < 0) x = 0;
if (y < 0) y = 0;
if (regions[x][y][0] == null) { // create the region
regions[x][y][0] = doc.createElement("Folder");
regions[x][y][1] = doc.createElement("Folder");
parent.appendChild(regions[x][y][0]);
parent.appendChild(regions[x][y][1]);
Element region = doc.createElement("Region");
Element latLonBox = doc.createElement("LatLonAltBox");
region.appendChild(latLonBox);
int boundX = -180 + LON_PARTITION_N * x;
int boundY = -90 + LAT_PARTITION_N * y;
Element leaf = doc.createElement("north");
leaf.appendChild(doc.createTextNode((boundY + LAT_PARTITION_N) + ""));
latLonBox.appendChild(leaf);
leaf = doc.createElement("south");
leaf.appendChild(doc.createTextNode(boundY + ""));
latLonBox.appendChild(leaf);
leaf = doc.createElement("east");
leaf.appendChild(doc.createTextNode((boundX + LON_PARTITION_N) + ""));
latLonBox.appendChild(leaf);
leaf = doc.createElement("west");
leaf.appendChild(doc.createTextNode(boundX + ""));
latLonBox.appendChild(leaf);
Element visibleRegion = (Element) region.cloneNode(true);
regions[x][y][0].appendChild(region);
regions[x][y][1].appendChild(visibleRegion);
Element lod = doc.createElement("Lod");
region.appendChild(lod);
leaf = doc.createElement("maxLodPixels");
leaf.appendChild(doc.createTextNode(LABEL_MIN_PIXELS));
lod.appendChild(leaf);
lod = doc.createElement("Lod");
visibleRegion.appendChild(lod);
leaf = doc.createElement("minLodPixels");
leaf.appendChild(doc.createTextNode(LABEL_MIN_PIXELS));
lod.appendChild(leaf);
}
return regions[x][y];
}
示例5: getObjectProviderConfiguration
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Gets a clone of the configuration element for a qualified element. Note that this configuration reflects the
* state of things as they were when the configuration was loaded, applications may have programmatically removed
* builder, marshallers, and unmarshallers during runtime.
*
* @param qualifedName the namespace qualifed element name of the schema type of the object provider
*
* @return the object provider configuration element or null if no object provider is configured with that name
*
* @deprecated this method is deprecated with no replacement
*/
public static Element getObjectProviderConfiguration(QName qualifedName) {
Element configElement = configuredObjectProviders.get(qualifedName);
if (configElement != null) {
return (Element) configElement.cloneNode(true);
}
return null;
}
示例6: getValidatorSuiteConfiguration
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Gets a clone of the ValidatorSuite configuration element for the ID. Note that this configuration reflects the
* state of things as they were when the configuration was loaded, applications may have programmatically removed
* altered the suite during runtime.
*
* @param suiteId the ID of the ValidatorSuite whose configuration is to be retrieved
*
* @return the validator suite configuration element or null if no suite is configured with that ID
*
* @deprecated this method is deprecated with no replacement
*/
public static Element getValidatorSuiteConfiguration(String suiteId) {
Element configElement = validatorSuiteConfigurations.get(suiteId);
if (configElement != null) {
return (Element) configElement.cloneNode(true);
}
return null;
}