示例#1
0
 /**
  * The typed value of a list-valued node is obtained by tokenizing the string value and applying
  * a mapping function to the sequence of tokens. This method implements the mapping function. It
  * is for internal use only. For details see {@link org.orbeon.saxon.expr.MappingFunction}
  */
 public SequenceIterator map(Item item) throws XPathException {
   try {
     return atomicType.getTypedValue(item.getStringValue(), resolver, nameChecker);
   } catch (ValidationException err) {
     throw new XPathException(err);
   }
 }
示例#2
0
  /** Evaluate as an expression. */
  public Item evaluateItem(XPathContext context) throws XPathException {
    if (isLazyConstruction()
        && (context.getConfiguration().areAllNodesUntyped()
            || (validation == Validation.PRESERVE && getSchemaType() == null))) {
      return new UnconstructedDocument(this, context);
    } else {
      Controller controller = context.getController();
      DocumentInfo root;
      if (textOnly) {
        CharSequence textValue;
        if (constantText != null) {
          textValue = constantText;
        } else {
          FastStringBuffer sb = new FastStringBuffer(100);
          SequenceIterator iter = content.iterate(context);
          while (true) {
            Item item = iter.next();
            if (item == null) break;
            sb.append(item.getStringValueCS());
          }
          textValue = sb.condense();
        }
        root = new TextFragmentValue(textValue, getBaseURI());
        ((TextFragmentValue) root).setConfiguration(controller.getConfiguration());
      } else {
        try {
          XPathContext c2 = context.newMinorContext();
          c2.setOrigin(this);

          Builder builder = controller.makeBuilder();
          // builder.setSizeParameters(treeSizeParameters);
          builder.setLineNumbering(controller.getConfiguration().isLineNumbering());

          // receiver.setSystemId(getBaseURI());
          builder.setBaseURI(getBaseURI());
          builder.setTiming(false);

          PipelineConfiguration pipe = controller.makePipelineConfiguration();
          pipe.setHostLanguage(getHostLanguage());
          // pipe.setBaseURI(baseURI);
          builder.setPipelineConfiguration(pipe);

          c2.changeOutputDestination(
              null, builder, false, getHostLanguage(), validation, getSchemaType());
          Receiver out = c2.getReceiver();
          out.open();
          out.startDocument(0);

          content.process(c2);

          out.endDocument();
          out.close();

          root = (DocumentInfo) builder.getCurrentRoot();
        } catch (XPathException e) {
          e.maybeSetLocation(this);
          e.maybeSetContext(context);
          throw e;
        }
      }
      return root;
    }
  }