当前位置: 首页>>代码示例>>Java>>正文


Java Type类代码示例

本文整理汇总了Java中net.sf.saxon.type.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Type类属于net.sf.saxon.type包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChildElementIndexWithinParent

import net.sf.saxon.type.Type; //导入依赖的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;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:24,代码来源:SaxonNodeWrapper.java

示例2: sequenceToAttributeCollection

import net.sf.saxon.type.Type; //导入依赖的package包/类
protected Collection<Attribute> sequenceToAttributeCollection(Sequence seq) throws XPathException {
  ArrayList<Attribute> attrs = new ArrayList<Attribute>();
  Item item;
  SequenceIterator iter = seq.iterate();
  while ((item = iter.next()) != null) {                
    Object value;
    String type;
    boolean isSerialized;
    if (item instanceof NodeInfo) {
      value = serialize((NodeInfo) item);
      type = "node()";
      isSerialized = true;
    } else {                             
      value = SequenceTool.convertToJava(item);
      ItemType itemType = Type.getItemType(item, null);
      type = itemType.toString();
      isSerialized = false;
    }
    attrs.add(new Attribute(value, type, isSerialized));
  }
  return attrs;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:23,代码来源:ExtensionFunctionCall.java

示例3: hasNoNsChild

import net.sf.saxon.type.Type; //导入依赖的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;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:7,代码来源:SaxonElement.java

示例4: initializeNodeInfo

import net.sf.saxon.type.Type; //导入依赖的package包/类
private void initializeNodeInfo(@Nullable NodeInfo nodeInfo) {
    if (nodeInfo == null) {
        return;
    }

    int nodeKind = nodeInfo.getNodeKind();
    NodeInfo elemInfo = null;

    if (nodeKind == Type.ATTRIBUTE) {
        this.attrQname = new QName(nodeInfo.getPrefix(), nodeInfo.getURI(), nodeInfo.getLocalPart());

        elemInfo = nodeInfo.getParent();
    } else if (nodeKind == Type.ELEMENT) {
        elemInfo = nodeInfo;
    }

    if (elemInfo == null) {
        return;
    }

    this.elemQname = new QName(elemInfo.getPrefix(), elemInfo.getURI(), elemInfo.getLocalPart());
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:23,代码来源:SdcctLocation.java

示例5: buildIDIndex

import net.sf.saxon.type.Type; //导入依赖的package包/类
private void buildIDIndex(Element elem) {
	// walk the tree in reverse document order, to satisfy the XPath 1.0 rule
	// that says if an ID appears twice, the first one wins
	for (int i=elem.getChildCount(); --i >= 0 ; ) {
		Node child = elem.getChild(i);
		if (child instanceof Element) {
			buildIDIndex((Element)child);
		}
	}
	for (int i=elem.getAttributeCount(); --i >= 0 ; ) {
		Attribute att = elem.getAttribute(i);
		if (att.getType() == Attribute.Type.ID) {
			idIndex.put(att.getValue(), wrap(elem));
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:DocumentWrapper.java

示例6: processArc

import net.sf.saxon.type.Type; //导入依赖的package包/类
void processArc(PathMapArc arc) {
	NodeTest test = arc.getNodeTest();
	if (test == null) {
		addAnyNodeArc(arc);
	} else {
		switch (test.getPrimitiveType()) {
		case Type.TEXT:
			matchesText = true;
		case Type.NODE:
			addAnyNodeArc(arc);
			break;
		case Type.COMMENT:
			matchesComment = true;
			break;
		case Type.ELEMENT:
			addElementArc(arc);
			break;
		case Type.ATTRIBUTE:
			addAttributeArc(arc);
			break;
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:24,代码来源:PathMapFilter.java

示例7: startElement

import net.sf.saxon.type.Type; //导入依赖的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$
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:25,代码来源:PathMapFilter.java

示例8: attribute

import net.sf.saxon.type.Type; //导入依赖的package包/类
@Override
public void attribute(NodeName nameCode, SimpleType typeCode,
		CharSequence value, int locationId, int properties)
		throws XPathException {
	MatchContext mc = matchContext.getLast();
	if (!mc.matchedElement) {
		return;
	}
	if (nameCode.isInNamespace(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)) {
		super.attribute(nameCode, typeCode, value, locationId, properties);
		return;
	}
	if (mc.attributeArcs != null) {
		for (PathMapArc arc : mc.attributeArcs) {
			NodeTest test = arc.getNodeTest();
			if (test == null || test.matches(Type.ATTRIBUTE, nameCode, typeCode.getFingerprint())) {
				super.attribute(nameCode, typeCode, value, locationId, properties);
				return;
			} 
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:23,代码来源:PathMapFilter.java

示例9: NodeWrapper

import net.sf.saxon.type.Type; //导入依赖的package包/类
/**
 * This constructor is protected: nodes should be created using the wrap
 * factory method on the DocumentWrapper class
 *
 * @param node
 *            The XOM node to be wrapped
 * @param parent
 *            The NodeWrapper that wraps the parent of this node
 * @param index
 *            Position of this node among its siblings
 */
protected NodeWrapper(Node node, NodeWrapper parent, int index) {
	short kind;
	if (node instanceof Element) {
		kind = Type.ELEMENT;
	} else if (node instanceof Text) {
		kind = Type.TEXT;
	} else if (node instanceof Attribute) {
		kind = Type.ATTRIBUTE;
	} else if (node instanceof Comment) {
		kind = Type.COMMENT;
	} else if (node instanceof ProcessingInstruction) {
		kind = Type.PROCESSING_INSTRUCTION;
	} else if (node instanceof Document) {
		kind = Type.DOCUMENT;
	} else {
		throwIllegalNode(node); // moved out of fast path to enable better inlining
		return; // keep compiler happy
	}
	this.nodeKind = kind;
	this.node = node;
	this.parent = parent;
	this.index = index;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:35,代码来源:NodeWrapper.java

示例10: getDeclaredNamespaces

import net.sf.saxon.type.Type; //导入依赖的package包/类
@Override
public NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer) {
       if (nodeKind == Type.ELEMENT) {
           Element elem = (Element)node;
           int size = elem.getNamespaceDeclarationCount();
           if (size == 0) {
               return new NamespaceBinding[0];
           }
           NamespaceBinding[] result = (buffer != null && size <= buffer.length ? buffer : new NamespaceBinding[size]);
           for (int i=0; i < size; i++) {
               String prefix = elem.getNamespacePrefix(i);
               String uri = elem.getNamespaceURI(prefix);
               result[i] = new NamespaceBinding(prefix, uri);
           }
           if (size < result.length) {
               result[size] = null;
           }
           return result;
       }
       return null;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:22,代码来源:NodeWrapper.java

示例11: getChildren

import net.sf.saxon.type.Type; //导入依赖的package包/类
/**
 * Iterate the children and fill the 'children' vector. This is a memo
 * function and only has to do actual work once.
 */
private void getChildren() 
{
  if (children != null)
    return;

  children = new ArrayList();

  NodeInfo child;
  AxisIterator iter = wrapped.iterateAxis(Axis.CHILD);
  while ((child = (NodeInfo)iter.next()) != null) 
  {
    if (child.getNodeKind() == Type.ELEMENT ||
        child.getNodeKind() == Type.TEXT) 
    {
      children.add(new EasyNode(child));
    }
  }
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:23,代码来源:EasyNode.java

示例12: FollowingEnumeration

import net.sf.saxon.type.Type; //导入依赖的package包/类
public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) 
{
  super(node, nodeTest);
  root = (LazyDocument)node.getDocumentRoot();

  // skip the descendant nodes if any
  int type = node.getNodeKind();
  if (type == Type.ATTRIBUTE || type == Type.NAMESPACE) 
  {
    next = ((NodeImpl)node.getParent()).getNextInDocument(root);
  }
  else {
    do {
      next = (NodeImpl)node.getNextSibling();
      if (next == null)
        node = (NodeImpl)node.getParent();
    } while (next == null && node != null);
  }
  while (!conforms(next)) {
    step();
  }
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:23,代码来源:FollowingEnumeration.java

示例13: getNodeNum

import net.sf.saxon.type.Type; //导入依赖的package包/类
/**
 * Retrieves the current node number in the build. Indexer uses this to
 * record node numbers in text chunks.
 *
 * @param inBuilder     The builder gotten from begin()
 * @return              The current node number.
 */
public int getNodeNum(Receiver inBuilder) {
  HackedTinyBuilder builder = (HackedTinyBuilder)inBuilder;
  tree = builder.getTree();
  
  // Don't count the stopper at the end of the tiny tree.
  int nNodes = tree.getNumberOfNodes();
  while (nNodes > 0 && tree.getNodeKind(nNodes-1) == Type.STOPPER)
    nNodes--;
  return nNodes;
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:18,代码来源:LazyTreeBuilder.java

示例14: eval

import net.sf.saxon.type.Type; //导入依赖的package包/类
public Optional<Variable> eval(String expressionString) {
    QueryModule evaluatedModule = getModule();
    StaticContext wrappingContext = wrapContext(evaluatedModule);
    if (wrappingContext != null) {
        try {
            Expression expression = ExpressionTool.make(expressionString, wrappingContext, 0, Token.EOF, null);
            final ExpressionVisitor visitor = ExpressionVisitor.make(wrappingContext);
            expression = expression.typeCheck(visitor, new ContextItemStaticInfo(Type.ITEM_TYPE, true));
            SlotManager stackFrameMap = xPathContext.getStackFrame().getStackFrameMap();
            final int variables = stackFrameMap.getNumberOfVariables();
            ExpressionTool.allocateSlots(expression, variables, stackFrameMap);
            final SequenceIterator it = expression.iterate(xPathContext);
            String[] sequenceValue = SaxonItemConverter.getSequenceValue(it);
            if (sequenceValue != null) {
                return Optional.of(new Variable("evalResult", sequenceValue[1], sequenceValue[0]));
            } else {
                return Optional.empty();
            }
        } catch (AssertionError | Exception e) {
            System.err.println("Unable to evaluate: '" + expressionString + "'");
            e.printStackTrace();
            return Optional.empty();
        }
    }
    return Optional.empty();
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:27,代码来源:SaxonExpressionEvaluator.java

示例15: serializeItem

import net.sf.saxon.type.Type; //导入依赖的package包/类
/**
 * Serializes item after XPath or XQuery processor execution using Saxon.
 */
public static String serializeItem(Item item) throws XPathException {
	if (item instanceof NodeInfo) {
		int type = ((NodeInfo)item).getNodeKind();
        if (type == Type.DOCUMENT || type == Type.ELEMENT) {
         Properties props = new Properties();
         props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
         props.setProperty(OutputKeys.INDENT, "yes");

            StringWriter stringWriter = new java.io.StringWriter();
            QueryResult.serialize((NodeInfo)item, new StreamResult(stringWriter), props);
            stringWriter.flush();
            return stringWriter.toString().replaceAll(" xmlns=\"http\\://www.w3.org/1999/xhtml\"", "");
        }
	}
	
	return item.getStringValue();
}
 
开发者ID:huajun2013,项目名称:ablaze,代码行数:21,代码来源:CommonUtil.java


注:本文中的net.sf.saxon.type.Type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。