Package org.exist.dom

Examples of org.exist.dom.QName


    /* (non-Javadoc)
     * @see org.exist.xquery.Expression#analyze(org.exist.xquery.AnalyzeContextInfo)
     */
    public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
      contextInfo.setParent(this);
        final QName qn = QName.parse(context, qname, null);
        final Variable var = new VariableImpl(qn);
        var.setIsInitialized(false);
        if (!analyzeDone) {
            final Module myModule = context.getModule(qn.getNamespaceURI());
            if(myModule != null) {
// WM: duplicate var declaration is now caught in the XQuery tree parser
//                if (myModule.isVarDeclared(qn))
//                    throw new XPathException(this, "err:XQST0049: It is a static error if more than one " +
//                            "variable declared or imported by a module has the same expanded QName. Variable: " + qn);
View Full Code Here


                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);}
            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());}
        }
        context.pushInScopeNamespaces(false);
    final QName qn = QName.parse(context, qname, null);
       
    final Module myModule = context.getRootModule(qn.getNamespaceURI());   
        context.pushDocumentContext();
        context.prologEnter(this);
    // declare the variable
    final Sequence seq = expression.eval(null, null);
        Variable var;
View Full Code Here

            attributes = natts;
        }
  }
 
  public void addNamespaceDecl(String name, String uri) throws XPathException {
        final QName qn = new QName(name, uri, "xmlns");

        if (name.equalsIgnoreCase("xml") || name.equalsIgnoreCase("xmlns"))
            {throw new XPathException(this, ErrorCodes.XQST0070, "can not redefine '" + qn + "'");}
       
        if (uri.equalsIgnoreCase(Namespaces.XML_NS))
View Full Code Here

        } else {
            for(int i = 0; i < namespaceDecls.length; i++) {
                if (qn.equals(namespaceDecls[i]))
                    {throw new XPathException(this, ErrorCodes.XQST0071, "duplicate definition for '" + qn + "'");}
            }
            QName decls[] = new QName[namespaceDecls.length + 1];
            System.arraycopy(namespaceDecls, 0, decls, 0, namespaceDecls.length);
            decls[namespaceDecls.length] = qn;         
            namespaceDecls = decls;
        }
        //context.inScopeNamespaces.put(qn.getLocalName(), qn.getNamespaceURI());
View Full Code Here

            // process attributes
            final AttributesImpl attrs = new AttributesImpl();
            if(attributes != null) {
                AttributeConstructor constructor;
                Sequence attrValues;
                QName attrQName;
                // first, search for xmlns attributes and declare in-scope namespaces
                for (int i = 0; i < attributes.length; i++) {
                    constructor = attributes[i];
                    if(constructor.isNamespaceDeclaration()) {
                        final int p = constructor.getQName().indexOf(':');
                        if(p == Constants.STRING_NOT_FOUND)
                            {context.declareInScopeNamespace("", constructor.getLiteralValue());}
                        else {
                            final String prefix = constructor.getQName().substring(p + 1);
                            context.declareInScopeNamespace(prefix, constructor.getLiteralValue());
                        }
                    }
                }
                String v = null;
                // process the remaining attributes
                for (int i = 0; i < attributes.length; i++) {
                    context.proceed(this, builder);
                    constructor = attributes[i];
                    attrValues = constructor.eval(contextSequence, contextItem);
                    attrQName = QName.parse(context, constructor.getQName(), "");
                   
                    final String namespaceURI = attrQName.getNamespaceURI();
                if (namespaceURI != null && !namespaceURI.isEmpty() && attrQName.getPrefix() == null) {
                  String prefix = context.getPrefixForURI(namespaceURI);
                 
                  if (prefix != null) {
                    attrQName.setPrefix(prefix);
                  } else {
                    //generate prefix
                    for (final int n = 1; i < 100; i++) {
                      prefix = "eXnsp"+n;
                            if (context.getURIForPrefix(prefix) == null) {
                              attrQName.setPrefix(prefix);
                              break;
                            }
                           
                            prefix = null;
                    }
                    if (prefix == null)
                                {throw new XPathException(this, "Prefix can't be generate.");}
                  }
                }
                   
                    if (attrs.getIndex(attrQName.getNamespaceURI(), attrQName.getLocalName()) != -1)
                        {throw new XPathException(this, ErrorCodes.XQST0040, "'" + attrQName.getLocalName() + "' is a duplicate attribute name");}
                   
                    v = DynamicAttributeConstructor.normalize(this, attrQName, attrValues.getStringValue());
                   
                    attrs.addAttribute(attrQName.getNamespaceURI(), attrQName.getLocalName(),
                            attrQName.getStringValue(), "CDATA", v);
                }
            }
            context.proceed(this, builder);

            // create the element
            final Sequence qnameSeq = qnameExpr.eval(contextSequence, contextItem);
            if(!qnameSeq.hasOne())
              {throw new XPathException(this, ErrorCodes.XPTY0004, "Type error: the node name should evaluate to a single item");}
            final Item qnitem = qnameSeq.itemAt(0);
            QName qn;
            if (qnitem instanceof QNameValue) {
                qn = ((QNameValue)qnitem).getQName();
            } else {
                //Do we have the same result than Atomize there ? -pb
              try {
                qn = QName.parse(context, qnitem.getStringValue());
              } catch (final IllegalArgumentException e) {
              throw new XPathException(this, ErrorCodes.XPTY0004, "" + qnitem.getStringValue() + "' is not a valid element name");
              } catch (final XPathException e) {
                e.setLocation(getLine(), getColumn(), getSource());
                throw e;
        }
             
                //Use the default namespace if specified
                /*
                 if (qn.getPrefix() == null && context.inScopeNamespaces.get("xmlns") != null) {
                     qn.setNamespaceURI((String)context.inScopeNamespaces.get("xmlns"));
                 }
                 */
                if (qn.getPrefix() == null && context.getInScopeNamespace("") != null) {
                     qn.setNamespaceURI(context.getInScopeNamespace(""));
                }
             }

            //Not in the specs but... makes sense
            if(!XMLChar.isValidName(qn.getLocalName()))
              {throw new XPathException(this, ErrorCodes.XPTY0004, "'" + qnitem.getStringValue() + "' is not a valid element name");}

            // add namespace declaration nodes
            final int nodeNr = builder.startElement(qn, attrs);
            if(namespaceDecls != null) {
                for(int i = 0; i < namespaceDecls.length; i++) {
                    builder.namespaceNode(namespaceDecls[i]);
                }
            }
            // do we need to add a namespace declaration for the current node?
            if (qn.needsNamespaceDecl()) {
                if (context.getInScopePrefix(qn.getNamespaceURI()) == null) {
                    String prefix = qn.getPrefix();
                    if (prefix == null || prefix.length() == 0)
                        {prefix = "";}
                    context.declareInScopeNamespace(prefix, qn.getNamespaceURI());
                    builder.namespaceNode(new QName(prefix, qn.getNamespaceURI(), "xmlns"));
                }
            } else if ((qn.getPrefix() == null || qn.getPrefix().length() == 0) &&
                context.getInheritedNamespace("") != null) {
                context.declareInScopeNamespace("", "");
                builder.namespaceNode(new QName("", "", "xmlns"));
            }
            // process element contents
            if(content != null) {
                content.eval(contextSequence, contextItem);
            }
View Full Code Here

    public static ErrorCode DEBUG001 = new DebugErrorCode("DEBUG001", "Debugger command error.");

    public static class DebugErrorCode extends ErrorCode {
        private DebugErrorCode(String code, String description) {
            super(new QName(code, NAMESPACE_URI, PREFIX), description);
        }
View Full Code Here

            return;
       
        EntityCursor<MetaImpl> sub = metadata.subIndex(metas.getUUID()).entities();
        try {
            for (MetaImpl m : sub)
                listener.metadata(new QName(m.getKey(), MDStorageManager.NAMESPACE_URI, MDStorageManager.PREFIX) , m.getValue());

        } finally {
            sub.close();
        }
    }
View Full Code Here

          {newParamTypes.add(paramTypes[i]);}
        else
          // overloaded function: add last sequence type
          {newParamTypes.add(paramTypes[paramTypes.length - 1]);}
        // create local parameter variables
        final QName varName = new QName("vp" + i);
        variables.add(varName);
        // the argument to the inner call is a variable ref
        final VariableReference ref = new VariableReference(context, varName.toString());
        callArgs.add(ref);
      } else {
        // fixed argument: just compute the argument value
        try {
                    param.analyze(cachedContextInfo);
          final Sequence seq = param.eval(contextSequence, contextItem);
          callArgs.add(new PrecomputedValue(context, seq));
        } catch (final XPathException e) {
          if(e.getLine() <= 0) {
            e.setLocation(line, column, getSource());
          }
          // append location of the function call to the exception message:
          e.addFunctionCall(function.functionDef, this);
          throw e;
        }
      }
    }
    final SequenceType[] newParamArray = newParamTypes.toArray(new SequenceType[newParamTypes.size()]);
    final QName name = new QName(PARTIAL_FUN_PREFIX + hashCode());
    final FunctionSignature newSignature = new FunctionSignature(name, newParamArray, signature.getReturnType());
    final UserDefinedFunction func = new UserDefinedFunction(context, newSignature);
    func.setLocation(staticCall.getLine(), staticCall.getColumn());
   
    // add the created parameter variables to the function
View Full Code Here

    public static final String DISABLE_DEPRECATED_FUNCTIONS_ATTRIBUTE = "disable-deprecated-functions";
    public static final String PROPERTY_DISABLE_DEPRECATED_FUNCTIONS = "xquery.disable-deprecated-functions";
    public static final boolean DISABLE_DEPRECATED_FUNCTIONS_BY_DEFAULT = false;

    public static Expression createFunction(XQueryContext context, XQueryAST ast, PathExpr parent, List<Expression> params) throws XPathException {
      QName qname = null;
        try {
            qname = QName.parse(context, ast.getText(), context.getDefaultFunctionNamespace());
        } catch(final XPathException xpe) {
            xpe.setLocation(ast.getLine(), ast.getColumn());
            throw xpe;
View Full Code Here

    final List<SequenceType> newParamTypes = new ArrayList<SequenceType>();
    final SequenceType[] paramTypes = signature.getArgumentTypes();
    for (int i = 0; i < argCount; i++) {
      final Expression param = call.getArgument(i);
      wrapperArgs.add(param);
      QName varName = new QName("vp" + i);
      variables[i] = varName;
      final VariableReference ref = new VariableReference(context, varName.toString());
      innerArgs.add(ref);
     
      // copy parameter sequence types
      // overloaded functions like concat may have an arbitrary number of arguments
      if (i < paramTypes.length)
View Full Code Here

TOP

Related Classes of org.exist.dom.QName

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.