本文整理汇总了Java中org.w3c.dom.Attr.getSpecified方法的典型用法代码示例。如果您正苦于以下问题:Java Attr.getSpecified方法的具体用法?Java Attr.getSpecified怎么用?Java Attr.getSpecified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Attr
的用法示例。
在下文中一共展示了Attr.getSpecified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: normalizeAttributeValue
import org.w3c.dom.Attr; //导入方法依赖的package包/类
final String normalizeAttributeValue(String value, Attr attr) {
if (!attr.getSpecified()){
// specified attributes should already have a normalized form
// since those were added by validator
return value;
}
int end = value.length();
// ensure capacity
if (fNormalizedValue.ch.length < end) {
fNormalizedValue.ch = new char[end];
}
fNormalizedValue.length = 0;
boolean normalized = false;
for (int i = 0; i < end; i++) {
char c = value.charAt(i);
if (c==0x0009 || c==0x000A) {
fNormalizedValue.ch[fNormalizedValue.length++] = ' ';
normalized = true;
}
else if(c==0x000D){
normalized = true;
fNormalizedValue.ch[fNormalizedValue.length++] = ' ';
int next = i+1;
if (next < end && value.charAt(next)==0x000A) i=next; // skip following xA
}
else {
fNormalizedValue.ch[fNormalizedValue.length++] = c;
}
}
if (normalized){
value = fNormalizedValue.toString();
attr.setValue(value);
}
return value;
}
示例2: isAttributeSpecified
import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
* 5. [specified] A flag indicating whether this attribute was actually
* specified in the start-tag of its element, or was defaulted from the
* DTD.
*
* @param attributeHandle the attribute handle
* @return <code>true</code> if the attribute was specified;
* <code>false</code> if it was defaulted.
*/
public boolean isAttributeSpecified(int attributeHandle)
{
int type = getNodeType(attributeHandle);
if (DTM.ATTRIBUTE_NODE == type)
{
Attr attr = (Attr)getNode(attributeHandle);
return attr.getSpecified();
}
return false;
}
示例3: startElement
import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
* The start of an element.
*
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
*
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
Element currentElement = (Element) fCurrentNode;
int attrCount = attributes.getLength();
if (DEBUG_EVENTS) {
System.out.println("==>startElement: " +element+
" attrs.length="+attrCount);
}
for (int i = 0; i < attrCount; i++) {
attributes.getName(i, fAttrQName);
Attr attr = null;
attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
AttributePSVI attrPSVI =
(AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
if (attrPSVI != null) {
//REVISIT: instead we should be using augmentations:
// to set/retrieve Id attributes
XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
boolean id = false;
if (decl != null){
id = ((XSSimpleType)decl).isIDType();
} else{
decl = attrPSVI.getTypeDefinition();
if (decl !=null){
id = ((XSSimpleType)decl).isIDType();
}
}
if (id){
((ElementImpl)currentElement).setIdAttributeNode(attr, true);
}
if (fPSVI) {
((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
}
if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
// datatype-normalization
// NOTE: The specified value MUST be set after we set
// the node value because that turns the "specified"
// flag to "true" which may overwrite a "false"
// value from the attribute list.
boolean specified = attr.getSpecified();
attr.setValue(attrPSVI.getSchemaNormalizedValue());
if (!specified) {
((AttrImpl) attr).setSpecified(specified);
}
}
}
}
}
示例4: startElement
import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
* The start of an element.
*
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
*
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
Element currentElement = (Element) fCurrentNode;
int attrCount = attributes.getLength();
if (DEBUG_EVENTS) {
System.out.println("==>startElement: " +element+
" attrs.length="+attrCount);
}
for (int i = 0; i < attrCount; i++) {
attributes.getName(i, fAttrQName);
Attr attr = null;
attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
AttributePSVI attrPSVI =
(AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
if (attrPSVI != null) {
//REVISIT: instead we should be using augmentations:
// to set/retrieve Id attributes
XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
boolean id = false;
if (decl != null){
id = ((XSSimpleType)decl).isIDType();
} else{
decl = attrPSVI.getTypeDefinition();
if (decl !=null){
id = ((XSSimpleType)decl).isIDType();
}
}
if (id){
((ElementImpl)currentElement).setIdAttributeNode(attr, true);
}
if (fPSVI) {
((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
}
if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
// datatype-normalization
// NOTE: The specified value MUST be set after we set
// the node value because that turns the "specified"
// flag to "true" which may overwrite a "false"
// value from the attribute list.
boolean specified = attr.getSpecified();
attr.setValue(attrPSVI.getSchemaValue().getNormalizedValue());
if (!specified) {
((AttrImpl) attr).setSpecified(specified);
}
}
}
}
}