热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javagetattributeintvalue_JavaNode.getAttribute方法代碼示例

importorg.cybergarage.xml.Node;導入方法依賴的package包類***throwsI2PParserExceptionifanynodenotinwh

import org.cybergarage.xml.Node; //導入方法依賴的package包/類

/**

* @throws I2PParserException if any node not in whitelist (depends on mode)

* @return true if node was removed from parent (only for REMOVE_ELEMENT mode)

*/

private boolean validate(Node node) throws I2PParserException {

String name = node.getName();

//if (_log.shouldLog(Log.DEBUG))

// _log.debug("Validating element: " + name);

if (!xhtmlWhitelist.contains(name.toLowerCase(Locale.US))) {

switch (_mode) {

case ABORT:

case SKIP_ENTRY:

throw new I2PParserException("Invalid XHTML element \"" + name + '"');

case REMOVE_ATTRIBUTE:

case REMOVE_ELEMENT:

if (_log.shouldLog(Log.WARN))

_log.warn("Removing element: " + node);

node.getParentNode().removeNode(node);

return true;

case ALLOW_ALL:

if (_log.shouldLog(Log.WARN))

_log.warn("Allowing non-whitelisted element by configuration: " + node);

break;

}

}

for (int i = 0; i

Attribute attr = node.getAttribute(i);

String aname = attr.getName();

if (attributeBlacklist.contains(aname.toLowerCase(Locale.US))) {

switch (_mode) {

case ABORT:

case SKIP_ENTRY:

throw new I2PParserException("Invalid XHTML element \"" + name + "\" due to attribute " + aname);

case REMOVE_ELEMENT:

if (_log.shouldLog(Log.WARN))

_log.warn("Removing element: " + node + " due to attribute " + aname);

node.getParentNode().removeNode(node);

return true;

case REMOVE_ATTRIBUTE:

if (_log.shouldLog(Log.WARN))

_log.warn("Removing attribute: " + aname + " from " + node);

// sadly, no removeAttribute(int)

if (node.removeAttribute(attr))

i--;

break;

case ALLOW_ALL:

if (_log.shouldLog(Log.WARN))

_log.warn("Allowing blacklisted attribute by configuration: " + node);

break;

}

}

}

int count = node.getNNodes();

for (int i = 0; i

boolean removed = validate(node.getNode(i));

if (removed)

i--;

}

return false;

}



推荐阅读
author-avatar
18岁的淡淡淡色彩
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有