net.sf.saxon.om.Item.getStringValue()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中net.sf.saxon.om.Item.getStringValue()方法的一些代码示例,展示了Item.getStringValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getStringValue()方法的具体详情如下:
包路径:net.sf.saxon.om.Item
类名称:Item
方法名:getStringValue

Item.getStringValue介绍

[英]Get the value of the item as a string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.

If the calling code can handle any CharSequence, the method #getStringValueCS should be used. If the caller requires a string, this method is preferred.
[中]以字符串形式获取项的值。对于节点,这是XPath 2.0数据模型中定义的节点的字符串值,但所有节点都被视为非类型化:获取复杂类型节点的字符串值不是错误。对于原子值,该方法返回将原子值强制转换为字符串的结果。
如果调用代码可以处理任何CharSequence,则应使用方法#getStringValueCS。如果调用方需要字符串,则首选此方法。

代码示例

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Convert the value to a string, using the serialization rules.
 * For atomic values this is the same as a cast; for sequence values
 * it gives a space-separated list. For QNames and NOTATIONS, or lists
 * containing them, it fails.
 */
/*@NotNull*/
public String getStringValue() {
  return item == null ? "" : item.getStringValue();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

/**
 * Convert the value to a string, using the serialization rules.
 * For atomic values this is the same as a cast; for sequence values
 * it gives a space-separated list. For QNames and NOTATIONS, or lists
 * containing them, it fails.
 */
/*@NotNull*/
public String getStringValue() {
  return item == null ? "" : item.getStringValue();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

public String getText() {
  if (currentStaxEvent != CHARACTERS && currentStaxEvent != COMMENT) {
    throw new IllegalStateException(""+currentStaxEvent);
  }
  if (previousAtomic) {
    return currentTextNode.toString();
  } else {
    return currentItem.getStringValue();
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public String convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException {
  Item first = value.head();
  return first == null ? null : first.getStringValue();
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

@Override
public StringValue evaluate(Item arg, XPathContext context) {
  return StringValue.makeStringValue(arg.getStringValue().toLowerCase());
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

private String toSpaceSeparatedString(Sequence<?> seqVal) throws XPathException {
  SequenceIterator<?> iterator = seqVal.iterate();
  Item item;
  StringBuilder stringVal = new StringBuilder();
  while ((item = iterator.next()) != null) {
    stringVal.append(" ").append(item.getStringValue());
  }
  return stringVal.toString();
}

代码示例来源:origin: org.daisy.pipeline.modules.braille/liblouis-saxon

private static String[] sequenceToArray(Sequence seq) throws XPathException {
  List<String> list = new ArrayList<String>();
  SequenceIterator iterator = seq.iterate();
  for (Item item = iterator.next(); item != null; item = iterator.next())
    list.add(item.getStringValue());
  return list.toArray(new String[list.size()]);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException {
    try {
      return constructor.newInstance(value.head().getStringValue());
    } catch (InstantiationException | IllegalAccessException e) {
      throw new XPathException(e);
    } catch (InvocationTargetException e) {
      throw new XPathException("Cannot convert untypedAtomic to " + targetClass.getName() +
        ": " + e.getMessage(), "FORG0001");
    }
  }
};

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException {
    try {
      return constructor.newInstance(value.head().getStringValue());
    } catch (InstantiationException | IllegalAccessException e) {
      throw new XPathException(e);
    } catch (InvocationTargetException e) {
      throw new XPathException("Cannot convert untypedAtomic to " + targetClass.getName() +
        ": " + e.getMessage(), "FORG0001");
    }
  }
};

代码示例来源:origin: net.sourceforge.saxon/saxon

public Item map(Item item) throws XPathException {
    String b = baseURI;
    if (b==null) {
      if (item instanceof NodeInfo) {
        b = ((NodeInfo)item).getBaseURI();
      } else {
        b = stylesheetURI;
      }
    }
    return makeDoc(item.getStringValue(), b, context, locator);
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

public Item map(Item item) throws XPathException {
    String b = baseURI;
    if (b==null) {
      if (item instanceof NodeInfo) {
        b = ((NodeInfo)item).getBaseURI();
      } else {
        b = stylesheetURI;
      }
    }
    return makeDoc(item.getStringValue(), b, context, locator);
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-B

public Item map(Item item) throws XPathException {
    String b = baseURI;
    if (b==null) {
      if (item instanceof NodeInfo) {
        b = ((NodeInfo)item).getBaseURI();
      } else {
        b = stylesheetURI;
      }
    }
    return makeDoc(item.getStringValue(), b, context, locator);
  }
}

代码示例来源:origin: org.daisy.pipeline.modules.braille/liblouis-saxon

private static List<String> sequenceToList(Sequence seq) throws XPathException {
  List<String> list = new ArrayList<String>();
  SequenceIterator iterator = seq.iterate();
  for (Item item = iterator.next(); item != null; item = iterator.next())
    list.add(item.getStringValue());
  return list;
}

代码示例来源:origin: org.daisy.pipeline.modules.braille/dotify-saxon

private static List<String> sequenceToList(Sequence seq) throws XPathException {
  List<String> list = new ArrayList<String>();
  SequenceIterator iterator = seq.iterate();
  for (Item item = iterator.next(); item != null; item = iterator.next())
    list.add(item.getStringValue());
  return list;
}

代码示例来源:origin: net.sf.xsparql/xsparql-evaluator-sparql-arq

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public SequenceIterator call(SequenceIterator[] arguments,
    XPathContext context) throws XPathException {
  String id = arguments[0].next().getStringValue();
  ScopedDatasetManager.deleteScopedDataset(id);
  return EmptyIterator.getInstance();
}

代码示例来源:origin: net.sf.xsparql/xsparql-evaluator-sparql-arq

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public SequenceIterator call(SequenceIterator[] arguments,
  XPathContext context) throws XPathException {
 String id = arguments[0].next().getStringValue();
 ScopedDatasetManager.scopedDatasetPopResults(id);
 return EmptyIterator.getInstance();
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public void outputWarning(Item item, XPathContext context) {
  String id = item instanceof NodeInfo ?
      "the node " + Navigator.getPath((NodeInfo) item) :
      "the atomic value " + item.getStringValue();
  XPathException warning = new XPathException("No user-defined template rule matches " + id, "XTDE0555");
  context.getController().getErrorListener().warning(warning);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

public void outputWarning(Item item, XPathContext context) {
  String id = item instanceof NodeInfo ?
      "the node " + Navigator.getPath((NodeInfo) item) :
      "the atomic value " + item.getStringValue();
  XPathException warning = new XPathException("No user-defined template rule matches " + id, "XTDE0555");
  context.getController().getErrorListener().warning(warning);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

private String toMethodTypeString(Sequence<?> seqVal) throws XPathException {
  String stringVal;
  if (seqVal.head() instanceof QNameValue) {
    QNameValue qNameValue = (QNameValue) seqVal.head();
    stringVal = '{' + qNameValue.getComponent(AccessorFn.Component.NAMESPACE).toString() + '}' + qNameValue.getComponent(AccessorFn.Component.LOCALNAME);
  } else {
    stringVal = seqVal.head().getStringValue();
  }
  return stringVal;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

private String toMethodTypeString(Sequence<?> seqVal) throws XPathException {
  String stringVal;
  if (seqVal.head() instanceof QNameValue) {
    QNameValue qNameValue = (QNameValue) seqVal.head();
    stringVal = '{' + qNameValue.getComponent(AccessorFn.Component.NAMESPACE).toString() + '}' + qNameValue.getComponent(AccessorFn.Component.LOCALNAME);
  } else {
    stringVal = seqVal.head().getStringValue();
  }
  return stringVal;
}

相关文章