本文整理汇总了Java中net.sf.saxon.om.AxisInfo类的典型用法代码示例。如果您正苦于以下问题:Java AxisInfo类的具体用法?Java AxisInfo怎么用?Java AxisInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AxisInfo类属于net.sf.saxon.om包,在下文中一共展示了AxisInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveToNode
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
public NodeInfo resolveToNode(List<Parameter> frameworkParameters) throws XPathException, TempContextException {
//logger.info("resolveToNode: " + getScriptName());
final NodeInfo resolvedNode = resolve(frameworkParameters);
NodeInfo resolvedElement = resolvedNode.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
//logger.info("needsReparse: " + XsltConref.needsReparse(resolvedElement));
if (XsltConref.needsReparse(resolvedElement)) {
final String serialized = SaxonNodeWrapper.serializeNode(resolvedNode);
try {
//logger.info("reparsing...");
//logger.info(serialized);
final XdmNode reparsedNode = xsltConrefCache.getDocumentBuilder().buildFromString(serialized, true);
resolvedElement = reparsedNode.getUnderlyingNode().iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
//logger.info("---");
//logger.info(SaxonNodeWrapper.serializeNode(reparsedElement));
} catch (SaxonApiException e) {
logger.info("------");
logger.info("serialized node:");
logger.info(serialized);
logger.info("------");
throw new XPathException("Failed to reparse resolved xslt-conref ('" + getScriptName() + "'): " + e.getMessage());
}
}
resolvedElement.setSystemId(node.getBaseUrl().toString());
return resolvedElement;
}
示例2: getChildElementIndexWithinParent
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public int getChildElementIndexWithinParent() {
final NodeInfo parent = saxonNode.getParent();
if (parent == null) {
return -1;
} else {
final AxisIterator iterator = saxonNode.getParent().iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
int index = 1;
NodeInfo sibling = null;
do {
sibling = iterator.next();
if (saxonNode.getNodeKind() == Type.ELEMENT) {
if (saxonNode.isSameNodeInfo(sibling)) {
//logger.info("getChildIndexWithinParent(" + saxonNode.getLocalPart() + "): " + index);
return index;
}
++index;
}
}
while (sibling != null);
}
return -1;
}
示例3: hasNoNsChild
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public boolean hasNoNsChild() throws HttpClientException {
NamePool pool = myNode.getConfiguration().getNamePool();
NodeTest no_ns_pred = new NamespaceTest(pool, Type.ELEMENT, "");
return myNode.iterateAxis(AxisInfo.CHILD, no_ns_pred).next() != null;
}
示例4: noOtherNCNameAttribute
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public void noOtherNCNameAttribute(String[] names) throws HttpClientException {
if (names == null) {
throw new NullPointerException("the names array is null");
}
String[] sorted = new String[names.length];
for (int i = 0; i < names.length; ++i) {
sorted[i] = names[i];
}
Arrays.sort(sorted);
String elem_name = myNode.getDisplayName();
AxisIterator it = myNode.iterateAxis(AxisInfo.ATTRIBUTE);
NodeInfo attr;
while ((attr = (NodeInfo) it.next()) != null) {
String attr_name = attr.getDisplayName();
if (HttpConstants.HTTP_CLIENT_NS_URI.equals(attr.getURI())) {
throw new HttpClientException("@" + attr_name + " not allowed on " + elem_name);
} else if (!"".equals(attr.getURI())) {
// ignore other-namespace-attributes
} else if (Arrays.binarySearch(sorted, attr.getLocalPart()) < 0) {
throw new HttpClientException("@" + attr_name + " not allowed on " + elem_name);
}
}
}
示例5: startElement
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public void startElement(NodeName elemName, SchemaType typeCode,
int locationId, int properties) throws XPathException {
MatchContext mc = matchContext.getLast();
MatchContext newContext = new MatchContext();
if (mc.elementArcs != null) {
for (PathMapArc arc : mc.elementArcs) {
NodeTest test = arc.getNodeTest();
if (test == null || test.matches(Type.ELEMENT, elemName, typeCode.getFingerprint())) {
newContext.bulidContext(arc.getTarget());
newContext.matchedElement = true;
}
if (arc.getAxis() == AxisInfo.DESCENDANT || arc.getAxis() == AxisInfo.DESCENDANT_OR_SELF) {
newContext.processArc(arc);
}
}
}
matchContext.add(newContext);
if (newContext.matchedElement) {
super.startElement(elemName, typeCode, locationId, properties);
} else if (logTrace) {
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Document projection did not match element", elemName.getURI(), ':', elemName.getLocalPart()); //$NON-NLS-1$
}
}
示例6: iterateAxis
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
/**
* Determines axis iteration algorithm. Throws {@code UnsupportedOperationException} in case,
* when there is no axis iterator for given axisNumber.
* @param axisNumber element from {@code AxisInfo}
* @return {@code AxisIterator} object
*/
@Override
public AxisIterator iterateAxis(byte axisNumber) {
final AxisIterator result;
switch (axisNumber) {
case AxisInfo.ANCESTOR:
case AxisInfo.ATTRIBUTE:
case AxisInfo.PARENT:
result = EmptyIterator.OfNodes.THE_INSTANCE;
break;
case AxisInfo.ANCESTOR_OR_SELF:
case AxisInfo.SELF:
result = SingleNodeIterator.makeIterator(this);
break;
case AxisInfo.CHILD:
if (hasChildNodes()) {
result = new ArrayIterator.OfNodes(
getChildren().toArray(new AbstractNode[getChildren().size()]));
}
else {
result = EmptyIterator.OfNodes.THE_INSTANCE;
}
break;
case AxisInfo.DESCENDANT:
if (hasChildNodes()) {
result = new Navigator.DescendantEnumeration(this, false, true);
}
else {
result = EmptyIterator.OfNodes.THE_INSTANCE;
}
break;
case AxisInfo.DESCENDANT_OR_SELF:
result = new Navigator.DescendantEnumeration(this, true, true);
break;
default:
throw throwUnsupportedOperationException();
}
return result;
}
示例7: testIterate
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Test
public void testIterate() {
try {
attributeNode.iterateAxis(AxisInfo.SELF);
fail("Exception is excepted");
}
catch (UnsupportedOperationException ex) {
assertEquals(
"Invalid exception message",
"Operation is not supported",
ex.getMessage());
}
}
示例8: testIterate
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Test
public void testIterate() {
assertEquals("Result iterator does not match expected",
EmptyIterator.OfNodes.THE_INSTANCE, rootNode.iterateAxis(AxisInfo.PARENT));
assertEquals("Result iterator does not match expected",
EmptyIterator.OfNodes.THE_INSTANCE, rootNode.iterateAxis(AxisInfo.PARENT,
null));
}
示例9: testRootWithNullDetailAst
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Test
public void testRootWithNullDetailAst() {
final RootNode emptyRootNode = new RootNode(null);
assertFalse("Empty node should not have children", emptyRootNode.hasChildNodes());
assertEquals("Invalid number of nodes", EmptyIterator.OfNodes.THE_INSTANCE,
emptyRootNode.iterateAxis(
AxisInfo.DESCENDANT));
assertEquals("Invalid number of nodes", EmptyIterator.OfNodes.THE_INSTANCE,
emptyRootNode.iterateAxis(AxisInfo.CHILD));
}
示例10: getAttributeNamesOfNamespace
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public List<String> getAttributeNamesOfNamespace(String namespaceUri) {
final List<String> list = new LinkedList<String>();
if (isElement()) {
final NodeTest nodeTest = new NamespaceTest(saxonNode.getNamePool(), Type.ATTRIBUTE, namespaceUri);
final AxisIterator iterator = saxonNode.iterateAxis(AxisInfo.ATTRIBUTE, nodeTest);
NodeInfo attribute = iterator.next();
while (attribute != null) {
list.add(attribute.getLocalPart());
attribute = iterator.next();
}
}
return list;
}
示例11: getChildNodes
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public List<NodeWrapper> getChildNodes() {
final AxisIterator iterator = saxonNode.iterateAxis(AxisInfo.CHILD);
final List<NodeWrapper> list = new LinkedList<>();
NodeInfo childNode = iterator.next();
while (childNode != null) {
list.add(new SaxonNodeWrapper(childNode, xPathCache));
childNode = iterator.next();
}
return list;
}
示例12: getValueOfChildElementByLocalName
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
public static String getValueOfChildElementByLocalName(NodeInfo parentElement, String localName, XPathContext context) {
NodeInfo nodeInfo = parentElement.iterateAxis(AxisInfo.CHILD, new LocalNameTest(context.getNamePool(), Type.ELEMENT, localName)).next();
if (nodeInfo != null) {
return nodeInfo.getStringValue();
}
return null;
}
示例13: getOutputProperties
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
protected Properties getOutputProperties(NodeInfo paramsElem) {
Properties props = new Properties();
paramsElem = unwrapNodeInfo(paramsElem);
AxisIterator iter = paramsElem.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
NodeInfo paramElem;
while ((paramElem = iter.next()) != null) {
props.put(paramElem.getLocalPart(), paramElem.getAttributeValue("", "value"));
}
return props;
}
示例14: createDocumentFromNodeInfo
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
public static Document createDocumentFromNodeInfo(NodeInfo nodeInfo,
DiffXML.WhitespaceStrippingPolicy whitespaceHandling) throws ParserConfigurationException {
if (nodeInfo.getNodeKind() == Type.DOCUMENT) {
nodeInfo = nodeInfo.iterateAxis(AxisInfo.CHILD).next();
}
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
docFactory.setValidating(false);
// docFactory.setExpandEntityReferences(true);
Document doc = docFactory.newDocumentBuilder().newDocument();
doc.setStrictErrorChecking(true); // TODO
doc.appendChild(createNodeFromNodeInfo(nodeInfo, doc, whitespaceHandling));
return doc;
}
示例15: getAttribute
import net.sf.saxon.om.AxisInfo; //导入依赖的package包/类
@Override
public String getAttribute(String local_name) throws HttpClientException {
// get the attribute
NamePool pool = myNode.getConfiguration().getNamePool();
NodeTest pred = new NameTest(Type.ATTRIBUTE, "", local_name, pool);
AxisIterator attrs = myNode.iterateAxis(AxisInfo.ATTRIBUTE, pred);
NodeInfo a = (NodeInfo) attrs.next();
// return its string value, or null if there is no such attribute
if (a == null) {
return null;
} else {
return a.getStringValue();
}
}