本文整理匯總了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);
}
}
}
}
}