本文整理汇总了Java中org.kxml2.kdom.Element.getAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getAttributeCount方法的具体用法?Java Element.getAttributeCount怎么用?Java Element.getAttributeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kxml2.kdom.Element
的用法示例。
在下文中一共展示了Element.getAttributeCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseMeta
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseMeta (Element e) {
List<String> usedAtts = new ArrayList<String>();
int attributes = e.getAttributeCount();
for(int i = 0 ; i < attributes ; ++i) {
String name = e.getAttributeName(i);
String value = e.getAttributeValue(i);
if("name".equals(name)) {
_f.setName(value);
}
}
usedAtts.add("name");
if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
示例2: getVagueElementPrintout
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static String getVagueElementPrintout(Element e, int maxDepth) {
String elementString = "<" + e.getName();
for(int i = 0; i < e.getAttributeCount() ; ++i) {
elementString += " " + e.getAttributeName(i) + "=\"";
elementString += e.getAttributeValue(i) + "\"";
}
if(e.getChildCount() > 0) {
elementString += ">";
if(e.getType(0) ==Element.ELEMENT) {
if(maxDepth > 0) {
elementString += getVagueElementPrintout((Element)e.getChild(0),maxDepth -1);
} else {
elementString += "...";
}
}
} else {
elementString += "/>";
}
return elementString;
}
示例3: parseMeta
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseMeta(Element e) {
Vector<String> usedAtts = new Vector<String>();
int attributes = e.getAttributeCount();
for (int i = 0; i < attributes; ++i) {
String name = e.getAttributeName(i);
String value = e.getAttributeValue(i);
if ("name".equals(name)) {
_f.setName(value);
}
}
usedAtts.addElement("name");
if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
示例4: getVagueElementPrintout
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static String getVagueElementPrintout(Element e, int maxDepth) {
String elementString = "<" + e.getName();
for (int i = 0; i < e.getAttributeCount(); ++i) {
elementString += " " + e.getAttributeName(i) + "=\"";
elementString += e.getAttributeValue(i) + "\"";
}
if (e.getChildCount() > 0) {
elementString += ">";
if (e.getType(0) == Element.ELEMENT) {
if (maxDepth > 0) {
elementString += getVagueElementPrintout((Element)e.getChild(0), maxDepth - 1);
} else {
elementString += "...";
}
}
} else {
elementString += "/>";
}
return elementString;
}
示例5: parseMeta
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseMeta(Element e) {
Vector<String> usedAtts = new Vector<>();
int attributes = e.getAttributeCount();
for (int i = 0; i < attributes; ++i) {
String name = e.getAttributeName(i);
String value = e.getAttributeValue(i);
if ("name".equals(name)) {
_f.setName(value);
}
}
usedAtts.addElement("name");
if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
示例6: copyBindingElement
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static Element copyBindingElement(Element element) {
Element retval = new Element();
retval.createElement(element.getNamespace(), element.getName());
for (int i = 0; i < element.getAttributeCount(); i++) {
retval.setAttribute(element.getAttributeNamespace(i), element.getAttributeName(i),
element.getAttributeValue(i));
}
return (retval);
}
示例7: processAdditionalAttributes
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
protected void processAdditionalAttributes(QuestionDef question, Element e, List<String> usedAtts) {
// save all the unused attributes verbatim...
for(int i=0;i<e.getAttributeCount();i++){
String name = e.getAttributeName(i);
if ( usedAtts.contains(name) ) continue;
question.setAdditionalAttribute(e.getAttributeNamespace(i), name, e.getAttributeValue(i));
}
if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
示例8: parseSubmission
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public SubmissionProfile parseSubmission(String method, String action, IDataReference ref, Element element) {
String mediatype = element.getAttributeValue(null,"mediatype");
HashMap<String,String> attributeMap = new HashMap<String,String>();
int nAttr = element.getAttributeCount();
for ( int i = 0 ; i < nAttr ; ++i ) {
String name = element.getAttributeName(i);
if ( name.equals("ref")) continue;
if ( name.equals("bind")) continue;
if ( name.equals("method")) continue;
if ( name.equals("action")) continue;
String value = element.getAttributeValue(i);
attributeMap.put(name, value);
}
return new SubmissionProfile(ref, method, action, mediatype, attributeMap);
}
示例9: getAttributeList
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static List<String> getAttributeList(Element e){
List<String> atts = new ArrayList<String>(e.getAttributeCount());
for(int i=0;i<e.getAttributeCount();i++){
atts.add(e.getAttributeName(i));
}
return atts;
}
示例10: parseSubmission
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public SubmissionProfile parseSubmission(String method, String action, XPathReference ref, Element element) {
String mediatype = element.getAttributeValue(null, "mediatype");
Hashtable<String, String> attributeMap = new Hashtable<String, String>();
int nAttr = element.getAttributeCount();
for (int i = 0; i < nAttr; ++i) {
String name = element.getAttributeName(i);
if (name.equals("ref")) continue;
if (name.equals("bind")) continue;
if (name.equals("method")) continue;
if (name.equals("action")) continue;
String value = element.getAttributeValue(i);
attributeMap.put(name, value);
}
return new SubmissionProfile(ref, method, action, mediatype, attributeMap);
}
示例11: getAttributeList
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
* Get the list of attributes in an element
*/
public static Vector<String> getAttributeList(Element e) {
Vector<String> atts = new Vector<String>();
for (int i = 0; i < e.getAttributeCount(); i++) {
atts.addElement(e.getAttributeName(i));
}
return atts;
}
示例12: attrTable
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static Hashtable<String, String> attrTable(Element element) {
Hashtable<String, String> attr = new Hashtable<>();
for(int i = 0 ; i < element.getAttributeCount() ; ++i ) {
attr.put(element.getAttributeName(i), element.getAttributeValue(i));
}
return attr;
}
示例13: getAttributeList
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
* Get the list of attributes in an element
*/
public static Vector<String> getAttributeList(Element e) {
Vector<String> atts = new Vector<>();
for (int i = 0; i < e.getAttributeCount(); i++) {
atts.addElement(e.getAttributeName(i));
}
return atts;
}
示例14: isDOMEqualRecursive
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static void isDOMEqualRecursive(Element left, Element right) throws RuntimeException {
if(!left.getName().equals(right.getName())) {
throw new RuntimeException(String.format("Mismatched element names '%s' and '%s'", left.getName(), right.getName()));
}
if(left.getAttributeCount() != right.getAttributeCount()) {
throw new RuntimeException(String.format("Mismatched attributes for node '%s' ", left.getName()));
}
Hashtable<String, String> leftAttr = attrTable(left);
Hashtable<String, String> rightAttr = attrTable(right);
for (String key : leftAttr.keySet()) {
if (!rightAttr.containsKey(key)) {
throw new RuntimeException(String.format("Mismatched attributes for node '%s' ", left.getName()));
}
if (!leftAttr.get(key).equals(rightAttr.get(key))) {
throw new RuntimeException(String.format("Mismatched attributes for node '%s' ", left.getName()));
}
}
if (left.getChildCount() != right.getChildCount()) {
throw new RuntimeException(String.format("Mismatched child count (%d,%d) for node '%s' ", left.getChildCount(), right.getChildCount(), left.getName()));
}
for (int i = 0; i < left.getChildCount(); ++i) {
Object l = left.getChild(i);
Object r = right.getChild(i);
if (left.getType(i) != right.getType(i)) {
throw new RuntimeException(String.format("Mismatched children for node '%s' ", left.getName()));
}
if(l instanceof Element) {
isDOMEqualRecursive((Element)l, (Element)r);
} else if(l instanceof String) {
if(!l.equals(r)) {
throw new RuntimeException(String.format("Mismatched element values '%s' and '%s'", l, r));
}
}
}
}
示例15: buildInstanceStructure
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/** parse instance hierarchy and turn into a skeleton model; ignoring data content, but respecting repeated nodes and 'template' flags */
public static TreeElement buildInstanceStructure(Element node, TreeElement parent, String instanceName, String docnamespace) {
TreeElement element = null;
//catch when text content is mixed with children
int numChildren = node.getChildCount();
boolean hasText = false;
boolean hasElements = false;
for (int i = 0; i < numChildren; i++) {
switch (node.getType(i)) {
case Node.ELEMENT:
hasElements = true;
break;
case Node.TEXT:
if (node.getText(i).trim().length() > 0)
hasText = true;
break;
}
}
if (hasElements && hasText) {
System.out.println("Warning: instance node '" + node.getName() + "' contains both elements and text as children; text ignored");
}
//check for repeat templating
String name = node.getName();
int multiplicity;
if (node.getAttributeValue(NAMESPACE_JAVAROSA, "template") != null) {
multiplicity = TreeReference.INDEX_TEMPLATE;
if (parent != null && parent.getChild(name, TreeReference.INDEX_TEMPLATE) != null) {
throw new XFormParseException("More than one node declared as the template for the same repeated set [" + name + "]", node);
}
} else {
multiplicity = (parent == null ? 0 : parent.getChildMultiplicity(name));
}
String modelType = node.getAttributeValue(NAMESPACE_JAVAROSA, "modeltype");
//create node; handle children
if (modelType == null) {
element = new TreeElement(name, multiplicity);
element.setInstanceName(instanceName);
} else {
if (typeMappings.get(modelType) == null) {
throw new XFormParseException("ModelType " + modelType + " is not recognized.", node);
}
element = new TreeElement(name, multiplicity);
}
if (node.getNamespace() != null) {
if (!node.getNamespace().equals(docnamespace)) {
element.setNamespace(node.getNamespace());
}
}
if (hasElements) {
for (int i = 0; i < numChildren; i++) {
if (node.getType(i) == Node.ELEMENT) {
element.addChild(buildInstanceStructure(node.getElement(i), element, instanceName, docnamespace));
}
}
}
//handle attributes
if (node.getAttributeCount() > 0) {
for (int i = 0; i < node.getAttributeCount(); i++) {
String attrNamespace = node.getAttributeNamespace(i);
String attrName = node.getAttributeName(i);
if (attrNamespace.equals(NAMESPACE_JAVAROSA) && attrName.equals("template")) {
continue;
}
if (attrNamespace.equals(NAMESPACE_JAVAROSA) && attrName.equals("recordset")) {
continue;
}
element.setAttribute(attrNamespace, attrName, node.getAttributeValue(i));
}
}
return element;
}