Examples of NameTest


Examples of net.sf.saxon.pattern.NameTest

    * @param fingerprint The fingerprint of the attribute name
    * @return the attribute value if it exists or null if not
    */

    public String getAttributeValue(int fingerprint) {
        NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, getNamePool());
        AxisIterator iterator = iterateAxis(Axis.ATTRIBUTE, test);
        NodeInfo attribute = (NodeInfo)iterator.next();
        if (attribute == null) {
            return null;
        } else {
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);
               
                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                 
                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                   
                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

    public Attr getAttributeNodeNS(String namespaceURI, String localName) {
        NamePool pool = node.getNamePool();
        int fingerprint = pool.getFingerprint((namespaceURI==null ? "" : namespaceURI), localName);
        if (fingerprint==-1) return null;
        NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, pool);
        AxisIterator atts = node.iterateAxis(Axis.ATTRIBUTE, test);
        return (Attr)wrap((NodeInfo)atts.next());
    }
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

    * @param fingerprint The fingerprint of the attribute name
    * @return the attribute value if it exists or null if not
    */

    public String getAttributeValue(int fingerprint) {
        NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, getNamePool());
        AxisIterator iterator = iterateAxis(Axis.ATTRIBUTE, test);
        NodeInfo attribute = (NodeInfo)iterator.next();
        if (attribute == null) {
            return null;
        } else {
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

                while (true) {
                    NodeInfo att1 = (NodeInfo)a1.next();
                    if (att1 == null) break;

                    AxisIterator a2iter = n2.iterateAxis(Axis.ATTRIBUTE,
                                            new NameTest(Type.ATTRIBUTE, att1.getFingerprint(), pool));
                    NodeInfo att2 = (NodeInfo)a2iter.next();

                    if (att2==null) {
                        explain(config, "one element has an attribute " +
                                config.getNamePool().getClarkName(att1.getFingerprint()) +
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

                schemaType = decl.getType();
                instr.setSchemaType(schemaType);
                    // TODO: this causes validation against the type, rather than the declaration:
                    // are identity constraints being tested on the top-level element?
                itemType = new CombinedNodeTest(
                        new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
                        Token.INTERSECT,
                        new ContentTypeTest(Type.ELEMENT, schemaType, config));
                try {
                    schemaType.analyzeContentExpression(content, Type.ELEMENT, env);
                } catch (XPathException e) {
                    e.setErrorCode(instr.isXSLT() ? "XTTE1510" : "XQDY0027");
                    e.setLocator(instr);
                    throw e;
                }
                SchemaType xsiType = instr.getXSIType(env);
                if (xsiType != null) {
                    xsiType.analyzeContentExpression(content, Type.ELEMENT, env);
                    try {
                        config.checkTypeDerivationIsOK(xsiType, schemaType, 0);
                    } catch (SchemaException e) {
                        throw new XPathException("The specified xsi:type " + xsiType.getDescription() +
                                " is not validly derived from the required type " + schemaType.getDescription());
                    }
                }
            } else if (validation == Validation.LAX) {
                SchemaDeclaration decl = config.getElementDeclaration(nameCode & 0xfffff);
                if (decl == null) {
                    env.issueWarning("There is no global element declaration for " +
                            env.getNamePool().getDisplayName(nameCode), instr);
                    itemType = new NameTest(Type.ELEMENT, nameCode, env.getNamePool());
//                    itemType = new CombinedNodeTest(
//                        new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
//                        Token.INTERSECT,
//                        new ContentTypeTest(Type.ELEMENT, Untyped.getInstance(), config));
                } else {
                    schemaType = decl.getType();
                    instr.setSchemaType(schemaType);
                    itemType = new CombinedNodeTest(
                            new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
                            Token.INTERSECT,
                            new ContentTypeTest(Type.ELEMENT, instr.getSchemaType(), config));
                    try {
                        schemaType.analyzeContentExpression(content, Type.ELEMENT, env);
                    } catch (XPathException e) {
                        e.setErrorCode(instr.isXSLT() ? "XTTE1515" : "XQDY0027");
                        e.setLocator(instr);
                        throw e;
                    }
                }
            } else if (validation == Validation.PRESERVE) {
                // we know the result will be an element of type xs:anyType
                itemType = new CombinedNodeTest(
                        new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
                        Token.INTERSECT,
                        new ContentTypeTest(Type.ELEMENT, AnyType.getInstance(), config));
            } else {
                // we know the result will be an untyped element
                itemType = new CombinedNodeTest(
                        new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
                        Token.INTERSECT,
                        new ContentTypeTest(Type.ELEMENT, Untyped.getInstance(), config));
            }
        } else {
            itemType = new CombinedNodeTest(
                    new NameTest(Type.ELEMENT, nameCode, env.getNamePool()),
                    Token.INTERSECT,
                    new ContentTypeTest(Type.ELEMENT, schemaType, config)
            );
            try {
                schemaType.analyzeContentExpression(content, Type.ELEMENT, env);
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

                kind = Type.ELEMENT;
                break;
        }
        NamePool pool = getUnderlyingNode().getNamePool();
        int nameCode = pool.allocate("", name.getNamespaceURI(), name.getLocalName());
        NameTest test = new NameTest(kind, nameCode, pool);
        AxisIterator base = getUnderlyingNode().iterateAxis(axis.getAxisNumber(), test);
        return new XdmSequenceIterator(base);
    }
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

      if (test == AnyNodeTest.getInstance()) { // performance hack
        test = null; // mark as AnyNodeTest
      }
      else if (test instanceof NameTest) {
        NameTest nt = (NameTest) test;
        if (nt.getPrimitiveType() == Type.ELEMENT) { // performance hack
          // mark as element name test
          NamePool pool = getNamePool();
          testLocalName = pool.getLocalName(nt.getFingerprint());
          testURI = pool.getURI(nt.getFingerprint());
        }
      }
      else if (test instanceof NodeKindTest) {
        if (test.getPrimitiveType() == Type.ELEMENT) { // performance hack
          // mark as element type test
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

            if (test == AnyNodeTest.getInstance()) { // performance hack
        test = null; // mark as AnyNodeTest
      }
      else if (test instanceof NameTest) {
        NameTest nt = (NameTest) test;
        if (nt.getPrimitiveType() == Type.ELEMENT) { // performance hack
          // mark as element name test
          NamePool pool = getNamePool();
          testLocalName = pool.getLocalName(nt.getFingerprint());
          testURI = pool.getURI(nt.getFingerprint());
        }
      }
      else if (test instanceof NodeKindTest) {
        if (test.getPrimitiveType() == Type.ELEMENT) { // performance hack
          // mark as element type test
View Full Code Here

Examples of net.sf.saxon.pattern.NameTest

        if (level == 0) {
            if (++count == 2) {
                checkAllowsMany(locationId);
            }
            ItemType type = new CombinedNodeTest(
                    new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()),
                    Token.INTERSECT,
                    new ContentTypeTest(Type.ATTRIBUTE, getConfiguration().getSchemaType(typeCode), getConfiguration()));
            checkItemType(type, locationId);
        }
        nextReceiver.attribute(nameCode, typeCode, value, locationId, properties);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.