本文整理汇总了Java中org.apache.xml.dtm.DTM.NAMESPACE_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java DTM.NAMESPACE_NODE属性的具体用法?Java DTM.NAMESPACE_NODE怎么用?Java DTM.NAMESPACE_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.xml.dtm.DTM
的用法示例。
在下文中一共展示了DTM.NAMESPACE_NODE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDefinedNSDecl
/**
* Returns whether a namespace is defined
*
*
* @param attr Namespace attribute node
* @param dtm The DTM that owns attr.
*
* @return True if the namespace is already defined in
* list of namespaces
*/
public static boolean isDefinedNSDecl(
SerializationHandler serializer,
int attr,
DTM dtm)
{
if (DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
{
// String prefix = dtm.getPrefix(attr);
String prefix = dtm.getNodeNameX(attr);
String uri = serializer.getNamespaceURIFromPrefix(prefix);
// String uri = getURI(prefix);
if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
return true;
}
return false;
}
示例2: postInitialization
/**
* After constructing the translet object, this method must be called to
* perform any version-specific post-initialization that's required.
*/
public final void postInitialization() {
// If the version of the translet had just one namesArray, split
// it into multiple fields.
if (transletVersion < VER_SPLIT_NAMES_ARRAY) {
int arraySize = namesArray.length;
String[] newURIsArray = new String[arraySize];
String[] newNamesArray = new String[arraySize];
int[] newTypesArray = new int[arraySize];
for (int i = 0; i < arraySize; i++) {
String name = namesArray[i];
int colonIndex = name.lastIndexOf(':');
int lNameStartIdx = colonIndex+1;
if (colonIndex > -1) {
newURIsArray[i] = name.substring(0, colonIndex);
}
// Distinguish attribute and element names. Attribute has
// @ before local part of name.
if (name.charAt(lNameStartIdx) == '@') {
lNameStartIdx++;
newTypesArray[i] = DTM.ATTRIBUTE_NODE;
} else if (name.charAt(lNameStartIdx) == '?') {
lNameStartIdx++;
newTypesArray[i] = DTM.NAMESPACE_NODE;
} else {
newTypesArray[i] = DTM.ELEMENT_NODE;
}
newNamesArray[i] =
(lNameStartIdx == 0) ? name
: name.substring(lNameStartIdx);
}
namesArray = newNamesArray;
urisArray = newURIsArray;
typesArray = newTypesArray;
}
// Was translet compiled using a more recent version of the XSLTC
// compiler than is known by the AbstractTranslet class? If, so
// and we've made it this far (which is doubtful), we should give up.
if (transletVersion > CURRENT_TRANSLET_VERSION) {
BasisLibrary.runTimeError(BasisLibrary.UNKNOWN_TRANSLET_VERSION_ERR,
this.getClass().getName());
}
}
示例3: getAttributeNode
/**
* Retrieves an attribute node by by qualified name and namespace URI.
*
* @param nodeHandle int Handle of the node upon which to look up this attribute..
* @param namespaceURI The namespace URI of the attribute to
* retrieve, or null.
* @param name The local name of the attribute to
* retrieve.
* @return The attribute node handle with the specified name (
* <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
* attribute.
*/
public int getAttributeNode(int nodeHandle, String namespaceURI,
String name)
{
// %OPT% This is probably slower than it needs to be.
if (null == namespaceURI)
namespaceURI = "";
int type = getNodeType(nodeHandle);
if (DTM.ELEMENT_NODE == type)
{
// Assume that attributes immediately follow the element.
int identity = makeNodeIdentity(nodeHandle);
while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
{
// Assume this can not be null.
type = _type(identity);
// %REVIEW%
// Should namespace nodes be retrievable DOM-style as attrs?
// If not we need a separate function... which may be desirable
// architecturally, but which is ugly from a code point of view.
// (If we REALLY insist on it, this code should become a subroutine
// of both -- retrieve the node, then test if the type matches
// what you're looking for.)
if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE)
{
Node node = lookupNode(identity);
String nodeuri = node.getNamespaceURI();
if (null == nodeuri)
nodeuri = "";
String nodelocalname = node.getLocalName();
if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname))
return makeNodeHandle(identity);
}
else // if (DTM.NAMESPACE_NODE != type)
{
break;
}
}
}
return DTM.NULL;
}
示例4: getNodeTypeTest
/**
* Tell what node type to test, if not DTMFilter.SHOW_ALL.
*
* @param whatToShow Bit set defined mainly by
* {@link org.apache.xml.dtm.DTMFilter}.
* @return the node type for the whatToShow. Since whatToShow can specify
* multiple types, it will return the first bit tested that is on,
* so the caller of this function should take care that this is
* the function they really want to call. If none of the known bits
* are set, this function will return zero.
*/
public static int getNodeTypeTest(int whatToShow)
{
// %REVIEW% Is there a better way?
if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
return DTM.ELEMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
return DTM.ATTRIBUTE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
return DTM.TEXT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
return DTM.DOCUMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
return DTM.DOCUMENT_FRAGMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
return DTM.NAMESPACE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
return DTM.COMMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
return DTM.PROCESSING_INSTRUCTION_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
return DTM.DOCUMENT_TYPE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
return DTM.ENTITY_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
return DTM.ENTITY_REFERENCE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
return DTM.NOTATION_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
return DTM.CDATA_SECTION_NODE;
return 0;
}