Package net.sf.saxon.om

Examples of net.sf.saxon.om.NamePool$NamePoolLimitException


    * Set the Configuration that contains this document
    */

    public void setConfiguration(Configuration config) {
        this.config = config;
        NamePool pool = config.getNamePool();
    documentNumber = pool.allocateDocumentNumber(this);
    }
View Full Code Here


                        uri = getURIForPrefix(prefix, false);
                        localName = parts[1];
                    } catch (QNameException err) {
                        compileError("Element name " + s + " is not a valid QName");
                    }
                    NamePool target = getTargetNamePool();
                    int nameCode = target.allocate("", uri, localName);
                    nt = new NameTest(Type.ELEMENT, nameCode, getNamePool());
                    pat.setNodeTest(nt);
                  stripperRules.addRule(
                        pat,
                        preserve,
View Full Code Here

        int num = attributeList.getLength();

        if (num == 0) {
            numberOfAttributes = 0;
        } else {
            NamePool namePool = getNamePool();
            attributeNames = new int[num];
            attributeValues = new Expression[num];
            attributeChecked = new boolean[num];
            numberOfAttributes = 0;

            for (int i=0; i<num; i++) {

                int anameCode = attributeList.getNameCode(i);
                short attURIcode = namePool.getURICode(anameCode);

                if (attURIcode==NamespaceConstant.XSLT_CODE) {
                    int fp = anameCode & 0xfffff;

                    if (fp == StandardNames.XSL_USE_ATTRIBUTE_SETS) {
                        // deal with this later
                    } else if (fp == StandardNames.XSL_EXTENSION_ELEMENT_PREFIXES) {
                      // already dealt with
                    } else if (fp == StandardNames.XSL_EXCLUDE_RESULT_PREFIXES) {
                      // already dealt with
                    } else if (fp == StandardNames.XSL_VERSION) {
                        // already dealt with
                    } else if (fp == StandardNames.XSL_XPATH_DEFAULT_NAMESPACE) {
                        // already dealt with
                    } else if (fp == StandardNames.XSL_TYPE) {
                        // deal with this later
                    } else if (fp == StandardNames.XSL_VALIDATION) {
                        // deal with this later
                    } else if (fp == StandardNames.XSL_INHERIT_NAMESPACES) {
                        String inheritAtt = attributeList.getValue(i);
                        if (inheritAtt.equals("yes")) {
                            inheritNamespaces = true;
                        } else if (inheritAtt.equals("no")) {
                            inheritNamespaces = false;
                        } else {
                            compileError("The xsl:inherit-namespaces attribute has permitted values (yes, no)");
                        }
                    } else {
                        compileError("Unknown XSL attribute " + namePool.getDisplayName(anameCode));
                    }
                } else {
                    attributeNames[numberOfAttributes] = anameCode;
                    Expression exp = makeAttributeValueTemplate(attributeList.getValue(i));
                    attributeValues[numberOfAttributes] = exp;
View Full Code Here

        toplevel = (getParentNode() instanceof XSLStylesheet);

        resultNameCode = getNameCode();

        NamePool namePool = getNamePool();
        short elementURICode = namePool.getURICode(resultNameCode);

        if (toplevel) {
            // A top-level element can never be a "real" literal result element,
            // but this class gets used for unknown elements found at the top level

            if (elementURICode == 0) {
                compileError("Top level elements must have a non-null namespace URI");
            }
        } else {

            // Build the list of output namespace nodes

            // Up to 5.3.1 we listed the namespace nodes associated with this element that were not also
            // associated with an ancestor literal result element (because those will already
            // have been output). Unfortunately this isn't true if the namespace was present on an outer
            // LRE, and was excluded at that level using exclude-result-prefixes, and is now used in an
            // inner element: bug 5.3.1/006

            // We now use a different optimisation: if
            // (a) this LRE has a parent that is also an LRE, and
            // (b) this LRE has no namespace declarations of its own, and
            // (c) this element name is in the same namespace as its parent, and
            // (d) the parent doesn't specify xsl:inherit-namespaces="no"
            // (e) there are no attributes in a non-null namespace,
            // then we don't need to output any namespace declarations to the result.

            boolean optimizeNS = false;
            NodeInfo parent = getParent();
            if ((parent instanceof LiteralResultElement) &&
                    ((LiteralResultElement)parent).inheritNamespaces &&
                    (namespaceList==null || namespaceList.length==0) &&
                    ( elementURICode == namePool.getURICode(getParent().getFingerprint()))) {
                optimizeNS = true;
            }
            if (optimizeNS) {
                for (int a=0; a<attributeList.getLength(); a++ ) {
                    if (((attributeList.getNameCode(a)>>20)&0xff) != 0) {  // prefix != ""
                        optimizeNS = false;
                        break;
                    }
                }
            }

            if (optimizeNS) {
              namespaceCodes = new int[0];
            } else {
                namespaceCodes = getNamespaceCodes();
          }

            // apply any aliases required to create the list of output namespaces

            XSLStylesheet sheet = getPrincipalStylesheet();

            if (sheet.hasNamespaceAliases()) {
                for (int i=0; i<namespaceCodes.length; i++) {
                  // System.err.println("Examining namespace " + namespaceCodes[i]);
                  short scode = (short)(namespaceCodes[i]&0xffff);
                    int ncode = sheet.getNamespaceAlias(scode);
                    if (ncode != -1 && (ncode & 0xffff) != scode) {
                        // apply the namespace alias. Change in 7.3: use the prefix associated
                        // with the new namespace, not the old prefix.
                        namespaceCodes[i] = ncode;
                    }
                }

                // determine if there is an alias for the namespace of the element name

                int ercode = sheet.getNamespaceAlias(elementURICode);
                if ((ercode & 0xffff) != elementURICode) {
                  elementURICode = (short)(ercode & 0xffff);
                    resultNameCode = namePool.allocate(namePool.getPrefixFromNamespaceCode(ercode),
                                                       namePool.getURIFromNamespaceCode(ercode),
                                                       getLocalPart());
                }
            }

            // deal with special attributes

            String useAttSets = getAttributeValue(StandardNames.XSL_USE_ATTRIBUTE_SETS);
            if (useAttSets != null) {
                attributeSets = getAttributeSets(useAttSets, null);
            }

            String type = getAttributeValue(StandardNames.XSL_TYPE);
            if (type != null) {
                if (!getConfiguration().isSchemaAware(Configuration.XSLT)) {
                    compileError("The xsl:type attribute is available only with a schema-aware XSLT processor");
                }
                schemaType = getSchemaType(type);
            }

            String validate = getAttributeValue(StandardNames.XSL_VALIDATION);
            if (validate != null) {
                validation = Validation.getCode(validate);
                if (validation != Validation.STRIP && !getConfiguration().isSchemaAware(Configuration.XSLT)) {
                    compileError("To perform validation, a schema-aware XSLT processor is needed");
                }
                if (validation == Validation.INVALID) {
                    compileError("Invalid value for xsl:validation. " +
                                 "Permitted values are (strict, lax, preserve, strip)");
                }
            } else {
                validation = getContainingStylesheet().getDefaultValidation();
            }

            // establish the names to be used for all the output attributes;
            // also type-check the AVT expressions

            short attributeURIs[] = new short[numberOfAttributes];
            if (numberOfAttributes > 0) {

                for (int i=0; i<numberOfAttributes; i++) {

                    int anameCode = attributeNames[i];
                    int alias = anameCode;
                    short attURIcode = namePool.getURICode(anameCode);

                    if (attURIcode!=0) {  // attribute has a namespace prefix
                        int newNSCode = sheet.getNamespaceAlias(attURIcode);
                        if ((newNSCode & 0xffff) != attURIcode) {
                          attURIcode = (short)(newNSCode & 0xffff);
                            alias = namePool.allocate( namePool.getPrefixFromNamespaceCode(newNSCode),
                                                       namePool.getURIFromNamespaceCode(newNSCode),
                                                       attributeList.getLocalName(i));
                        }
                    }

                  //attributeNames[i] = translate(alias);
                    attributeNames[i] = alias;
                  attributeURIs[i] = attURIcode;
                    attributeValues[i] = typeCheck(namePool.getDisplayName(alias), attributeValues[i]);
                }
            }

            // remove any namespaces that are on the exclude-result-prefixes list, unless it is
            // the namespace of the element or an attribute
View Full Code Here

            throws TransformerConfigurationException {

        // the implementation grafts the LRE node onto a containing xsl:template and
        // xsl:stylesheet

    NamePool pool = getNamePool();
        String xslPrefix = getPrefixForURI(NamespaceConstant.XSLT);
        if (xslPrefix==null) {
            String message;
            if (getLocalPart().equals("stylesheet") || getLocalPart().equals("transform")) {
                if (getPrefixForURI(NamespaceConstant.MICROSOFT_XSL)!=null) {
                    message = "Saxon is not able to process Microsoft's WD-xsl dialect";
                } else {
                    message = "Namespace for stylesheet element should be " + NamespaceConstant.XSLT;
                }
            } else {
                message = "The supplied file does not appear to be a stylesheet";
            }
            TransformerConfigurationException err = new TransformerConfigurationException (message);
            err.setLocator(this);
            try {
                pss.reportError(err);
            } catch (TransformerException err2) {}
            throw err;

        }

        // check there is an xsl:version attribute (it's mandatory), and copy
        // it to the new xsl:stylesheet element

        String version = getAttributeValue(StandardNames.XSL_VERSION);
        if (version==null) {
            TransformerConfigurationException err = new TransformerConfigurationException (
                "Literal Result Element As Stylesheet: xsl:version attribute is missing");
            err.setLocator(this);
            try {
                pss.reportError(err);
            } catch(TransformerException err2) {}
            throw err;
        }

        try {
            TreeBuilder builder = new TreeBuilder();
            builder.setDocumentLocator(null);
            builder.setConfiguration(pss.getConfiguration());
            builder.setNodeFactory(nodeFactory);
            builder.setSystemId(this.getSystemId());

            builder.open();

            int st = StandardNames.XSL_STYLESHEET;
            builder.startElement(st, -1, 0, 0);
            builder.namespace(NamespaceConstant.XSLT_CODE, 0);
            builder.attribute(pool.allocate("", "", "version"), -1, version, 0, 0);
            builder.startContent();

            int te = StandardNames.XSL_TEMPLATE;
            builder.startElement(te, -1, 0, 0);
            builder.attribute(pool.allocate("", "", "match"), -1, "/", 0, 0);
            builder.startContent();

            builder.graftElement(this);

            builder.endElement();
View Full Code Here

            String dbCol = arguments[COLUMN].evaluateAsString(context);
            String dbTab = arguments[TABLE].evaluateAsString(context);
            String dbWhere = arguments[WHERE].evaluateAsString(context);


            NamePool pool = controller.getNamePool();
            int rowCode = pool.allocate("", "", rowTag);
            int colCode = pool.allocate("", "", colTag);

            try {
                StringBuffer statement = new StringBuffer();
                statement.append("SELECT " + dbCol + " FROM " + dbTab);
                if (dbWhere!="")  {
View Full Code Here

    */

    public NamespaceImpl(ElementImpl element, int nsCode, int index) {
        this.parent = element;
        this.nsCode = nsCode;
        NamePool pool = getNamePool();
        this.nameCode = pool.allocate("", "", pool.getPrefixFromNamespaceCode(nsCode));
        this.index = index;
    }
View Full Code Here

    */

    public short getURICodeForPrefix(String prefix) throws NamespaceException {
        if (prefix.equals("xml")) return NamespaceConstant.XML_CODE;

    NamePool pool = getNamePool();
    int prefixCode = pool.getCodeForPrefix(prefix);
    if (prefixCode==-1) {
        throw new NamespaceException(prefix);
    }
    return getURICodeForPrefixCode(prefixCode);
    }
View Full Code Here

    */

    public String getPrefixForURI(String uri) {
        if (uri.equals(NamespaceConstant.XML)) return "xml";

    NamePool pool = getNamePool();
    int uriCode = pool.getCodeForURI(uri);
    if (uriCode<0) return null;
    return getPrefixForURICode(uriCode);
  }
View Full Code Here

            NodeInfo node = (NodeInfo)item;
            switch (node.getNodeKind()) {
                case DOCUMENT:
                    return "document-node()";
                case ELEMENT:
                    NamePool pool = node.getNamePool();
                    int annotation = node.getTypeAnnotation();
                    return "element(" +
                            ((NodeInfo)item).getDisplayName() + ", " +
                            (annotation == -1 ?
                                "xdt:untyped)" :
                                pool.getDisplayName(annotation) + ')');
                case ATTRIBUTE:
                    NamePool pool2 = node.getNamePool();
                    int annotation2 = node.getTypeAnnotation();
                    return "attribute(" +
                            ((NodeInfo)item).getDisplayName()+ ", " +
                            (annotation2 == -1 ?
                                "xdt:untypedAtomic)" :
                                pool2.getDisplayName(annotation2) + ')');
                case TEXT:      return "text()";
                case COMMENT:   return "comment()";
                case PROCESSING_INSTRUCTION:
                                return "processing-instruction()";
                case NAMESPACE: return "namespace()";
View Full Code Here

TOP

Related Classes of net.sf.saxon.om.NamePool$NamePoolLimitException

Copyright © 2018 www.massapicom. 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.