本文整理汇总了Java中net.sf.saxon.s9api.Axis类的典型用法代码示例。如果您正苦于以下问题:Java Axis类的具体用法?Java Axis怎么用?Java Axis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Axis类属于net.sf.saxon.s9api包,在下文中一共展示了Axis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildJavaStep
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private JavaStep buildJavaStep(XdmNode javaNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
LOGGER.trace("buildJavaStep on {}", javaNode.getNodeName());
JavaStep ret = new JavaStep(resolveEscapes(javaNode.getAttributeValue(JavaStep.ATTR_CLASS), parameters));
XdmSequenceIterator it = javaNode.axisIterator(Axis.CHILD, QN_PARAM);
while(it.hasNext()) {
ret.addParameter(buildParameter((XdmNode)it.next(),parameters));
}
return ret;
}
示例2: buildXslt
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Xslt buildXslt(XdmNode xsltNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
LOGGER.trace("buildXslt on {}", xsltNode.getNodeName());
Xslt ret = new Xslt(resolveEscapes(xsltNode.getAttributeValue(Xslt.ATTR_HREF),parameters));
if("true".equals(xsltNode.getAttributeValue(Xslt.ATTR_TRACE_ACTIVE))) {
ret.setTraceToAdd(true);
}
if("true".equals(xsltNode.getAttributeValue(Xslt.ATTR_DEBUG))) {
ret.setDebug(true);
ret.setId(xsltNode.getAttributeValue(Xslt.ATTR_ID));
}
XdmSequenceIterator it = xsltNode.axisIterator(Axis.CHILD, QN_PARAM);
while(it.hasNext()) {
ret.addParameter(buildParameter((XdmNode)it.next(),parameters));
}
return ret;
}
示例3: buildFile
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private CfgFile buildFile(XdmNode node, HashMap<QName,ParameterValue> parameters) throws URISyntaxException, InvalidSyntaxException {
String href = node.getAttributeValue(CfgFile.ATTR_HREF);
LOGGER.trace("buildFile from {} with href={}", node.getNodeName(), href);
File f;
href = resolveEscapes(href, parameters);
if(href.startsWith("file:")) {
f = new File(new URI(href));
} else {
f = new File(href);
if(!f.exists()) {
f = new File(currentDir, href);
}
}
LOGGER.trace("buildFile on {}", f.getName());
CfgFile ret = new CfgFile(f);
XdmSequenceIterator it = node.axisIterator(Axis.CHILD, QN_PARAM);
while(it.hasNext()) {
ret.addParameter(buildParameter((XdmNode)it.next(),parameters));
}
ParameterValue relativeFile = new ParameterValue(ParametersMerger.INPUT_RELATIVE_FILE, f.toURI().toString(), factory.XS_STRING);
ret.addParameter(relativeFile);
ParameterValue relativeDir = new ParameterValue(ParametersMerger.INPUT_RELATIVE_DIR, f.getParentFile().toURI().toString(), factory.XS_STRING);
ret.addParameter(relativeDir);
return ret;
}
示例4: getAssertionValue
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
String getAssertionValue(String text, XdmNode paramsVar) {
if (text.indexOf("$") < 0) {
return text;
}
String newText = text;
XdmNode params = (XdmNode) paramsVar.axisIterator(Axis.CHILD).next();
XdmSequenceIterator it = params.axisIterator(Axis.CHILD);
while (it.hasNext()) {
XdmNode n = (XdmNode) it.next();
QName qname = n.getNodeName();
if (qname != null) {
String tagname = qname.getLocalName();
if (tagname.equals("param")) {
String name = n.getAttributeValue(LOCALNAME_QNAME);
String label = getLabel(n);
newText = StringUtils.replaceAll(newText,
"{$" + name + "}", label);
}
}
}
newText = StringUtils.replaceAll(newText, "{$context}", contextLabel);
return newText;
}
示例5: buildTee
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Tee buildTee(XdmNode teeNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
LOGGER.trace("buildTee on "+teeNode.getNodeName());
Tee tee = new Tee();
XdmSequenceIterator seq = teeNode.axisIterator(Axis.CHILD,Pipe.QNAME);
while(seq.hasNext()) {
XdmNode node = (XdmNode)seq.next();
Pipe pipe = buildPipe(node, parameters, tee);
tee.addPipe(pipe);
}
return tee;
}
示例6: buildSources
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Sources buildSources(XdmNode sourcesNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
String orderBy = sourcesNode.getAttributeValue(Sources.ATTR_ORDERBY);
String sort = sourcesNode.getAttributeValue(Sources.ATTR_SORT);
LOGGER.trace("buildSources from {} with orderBy={} and sort={}", new Object[]{sourcesNode.getNodeName(), orderBy, sort});
Sources sources = new Sources(orderBy, sort);
XdmSequenceIterator it = sourcesNode.axisIterator(Axis.CHILD);
while(it.hasNext()) {
XdmNode node = (XdmNode)it.next();
LOGGER.trace("buildSource from {}", node.getNodeName());
if(CfgFile.QNAME.equals(node.getNodeName())) {
try {
CfgFile localFile = buildFile(node, parameters);
LOGGER.trace("add source {}", localFile);
sources.addFile(localFile);
} catch (URISyntaxException ex) {
LOGGER.error(ex.getMessage(),ex);
throw new InvalidSyntaxException(ex);
}
} else if(CfgFile.QN_FOLDER.equals(node.getNodeName())) {
Collection<CfgFile> files = buildFolderContent(node, parameters);
LOGGER.trace("buildSources from folder contains {} files", files.size());
sources.addFiles(files);
} else if(Listener.QName.equals(node.getNodeName())) {
sources.setListener(buildListener(node, parameters));
}
}
return sources;
}
示例7: buildListener
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Listener buildListener(XdmNode listenerNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
String tmp = resolveEscapes(listenerNode.getAttributeValue(Listener.ATTR_PORT),parameters);
int port = Listener.DEFAULT_PORT;
try {
port = Integer.parseInt(tmp);
} catch(NumberFormatException ex) {}
String stopKeyword = resolveEscapes(listenerNode.getAttributeValue(Listener.ATTR_STOP),parameters);
Listener list = new Listener(port, stopKeyword);
XdmSequenceIterator it = listenerNode.axisIterator(Axis.CHILD, JavaStep.QNAME);
if(it.hasNext()) {
list.setJavastep(buildJavaStep((XdmNode)it.next(), parameters));
}
return list;
}
示例8: buildWhen
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private WhenEntry buildWhen(XdmNode whenNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
String test = whenNode.getAttributeValue(WhenEntry.ATTR_TEST);
// particular case of the otherwise, which is implemented as a when[@test='true()']
if((test==null || test.length()==0) && WhenEntry.QN_OTHERWISE.equals(whenNode.getNodeName()) ) {
test="true()";
}
WhenEntry when = new WhenEntry(test);
XdmSequenceIterator it = whenNode.axisIterator(Axis.CHILD);
while(it.hasNext()) {
XdmItem item = it.next();
if(item instanceof XdmNode) {
XdmNode node = (XdmNode)item;
if(Xslt.QNAME.equals(node.getNodeName())) {
when.addStep(buildXslt(node,parameters));
} else if(JavaStep.QNAME.equals(node.getNodeName())) {
when.addStep(buildJavaStep(node, parameters));
} else if(ChooseStep.QNAME.equals(node.getNodeName())) {
when.addStep(buildChooseStep(node, parameters));
} else if(node.getNodeKind()==XdmNodeKind.TEXT) {
// on ignore
} else if(node.getNodeKind()==XdmNodeKind.COMMENT) {
// on ignore
} else {
throw new InvalidSyntaxException(node.getNodeKind().toString()+" - "+ node.getNodeName()+": unexpected element in "+Pipe.QNAME);
}
}
}
return when;
}
示例9: buildOutput
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Output buildOutput(XdmNode node, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
LOGGER.trace("buildOutput from {}", node.getNodeName());
Output ret = new Output();
// searching for output parameters
XdmSequenceIterator attributes = node.axisIterator(Axis.ATTRIBUTE);
while(attributes.hasNext()) {
XdmNode attr = (XdmNode)attributes.next();
ret.setOutputProperty(attr.getNodeName().getLocalName(), (String)resolveEscapes(attr.getStringValue(),parameters));
}
boolean nullOutput = node.axisIterator(Axis.CHILD, QN_NULL).hasNext();
if(nullOutput) {
ret.setNull(true);
} else {
XdmSequenceIterator consoleIterator = node.axisIterator(Axis.CHILD, Output.QN_CONSOLE);
if(consoleIterator.hasNext()) {
XdmNode console = (XdmNode)consoleIterator.next();
String sConsole = console.getAttributeValue(Output.ATTR_CONSOLE_WHICH);
if(sConsole==null) sConsole = "out";
ret.setConsole(sConsole);
} else {
XdmNode folder = (XdmNode)node.axisIterator(Axis.CHILD, CfgFile.QN_FOLDER).next();
String relative = resolveEscapes(folder.getAttributeValue(new QName("relative")),parameters);
String temp = folder.getAttributeValue(new QName("to"));
String to = resolveEscapes(temp, parameters);
String absolute = resolveEscapes(folder.getAttributeValue(new QName("absolute")), parameters);
if(relative!=null) ret.setRelativePath(relative);
if(to!=null) ret.setRelativeTo(to);
if(absolute!=null) ret.setAbsolute(absolute);
XdmNode filename = (XdmNode)node.axisIterator(Axis.CHILD, new QName(Config.NS,"fileName")).next();
String prefix = resolveEscapes(filename.getAttributeValue(new QName("prefix")),parameters);
String name = resolveEscapes(filename.getAttributeValue(new QName("name")),parameters);
String suffix = resolveEscapes(filename.getAttributeValue(new QName("suffix")), parameters);
if(prefix!=null) ret.setPrefix(prefix);
if(name!=null) ret.setName(name);
if(suffix!=null) ret.setSuffix(suffix);
}
}
return ret;
}
示例10: parseFile
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private void parseFile(String fileHddCachePath) {
//logger.info("parseFile: " + decodedUrl);
try {
containsUncachableXsltConref = false;
isFileParsed = true; // on failure the value remains true since a reparsing makes no sense.
final XdmNode rootNode = bookCache.getDocumentBuilder().build(source, expandAttributeDefaults);
final XdmSequenceIterator iterator = rootNode.axisIterator(Axis.CHILD);
//logger.info(SaxonNodeWrapper.serializeNode(rootNode.getUnderlyingNode()));
rootElement = null;
while ((iterator.hasNext()) && (rootElement == null)) {
final XdmNode child =(XdmNode)iterator.next();
//logger.info(" node: " + node.getNodeName() + ", " + node.getNodeKind());
if (child.getNodeKind() == XdmNodeKind.ELEMENT) {
rootElement = new SaxonNodeWrapper(child.getUnderlyingNode(), bookCache.getXPathCache());
}
}
if (rootElement != null) {
parseNode(rootElement.getNodeInfo(), this, null);
rootClass = rootElement.getAttribute(DitaUtil.ATTR_CLASS, null);
rootTitle = extractString(rootElement, LINK_TITLE_XSL);
rootName = rootElement.getName();
if ((fileHddCachePath != null) && (isHddCachable())) {
writeHddCache(fileHddCachePath, fileTimestamp);
}
}
} catch(SaxonApiException | TransformerException e) {
logger.error(e, e);
rootElement = null;
}
}
示例11: createKeyTypeDef
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
public void createKeyTypeDef(XdmNode node, KeyTypeDef parent) {
KeyTypeDef childParent = parent;
//logger.info("nodeName: " + node.getNodeName());
if (node.getNodeName().equals(NAME_KEY_TYPE_DEF)) {
final KeyTypeDef keyTypeDef = KeyTypeDef.fromNode(new SaxonNodeWrapper(node.getUnderlyingNode(), null), parent);
keyTypeDefByName.put(keyTypeDef.getName(), keyTypeDef);
childParent = keyTypeDef;
//logger.info("keyTypeDef: " + keyTypeDef);
}
final XdmSequenceIterator iterator = node.axisIterator(Axis.CHILD, NAME_KEY_TYPE_DEF);
while (iterator.hasNext()) {
createKeyTypeDef((XdmNode)iterator.next(), childParent);
}
}
示例12: parseKeyTypeDefSource
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
public void parseKeyTypeDefSource(Source source) {
try {
final XdmNode rootNode = documentBuilder.build(source, false);
final XdmSequenceIterator iterator = rootNode.axisIterator(Axis.CHILD, BookCache.NAME_KEY_TYPE_DEF_LIST);
while (iterator.hasNext()) {
createKeyTypeDef((XdmNode)iterator.next(), KeyTypeDef.DEFAULT);
}
} catch (Exception e) {
logger.error("Error parsing KeyTypeDef file '" + FileUtil.decodeUrl(source.getSystemId()) + "':");
logger.error(e, e);
}
}
示例13: createKeyTypeElement
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
private Sequence createKeyTypeElement(XPathContext context, String keyTypeName) throws XPathException {
final KeyTypeDef keyTypeDef = otResolver.getBookCache().getKeyTypeDef(keyTypeName);
final Processor processor = new Processor(context.getConfiguration());
final DocumentBuilder builder = processor.newDocumentBuilder();
try {
BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();
writer.writeStartElement(KeyTypeDef.ELEMENT);
writer.writeAttribute(KeyTypeDef.ATTR_NAME, keyTypeDef.getName());
writer.writeAttribute(KeyTypeDef.ATTR_IS_CODE_FONT, Boolean.toString(keyTypeDef.isCodeFont()));
writer.writeAttribute(KeyTypeDef.ATTR_IS_ITALIC_FONT, Boolean.toString(keyTypeDef.isItalicFont()));
writer.writeAttribute(KeyTypeDef.ATTR_PREFIX, keyTypeDef.getPrefix());
writer.writeAttribute(KeyTypeDef.ATTR_SUFFIX, keyTypeDef.getSuffix());
writer.writeAttribute(KeyTypeDef.ATTR_SELECT_PRIORITY, Integer.toString(keyTypeDef.getSelectPriority()));
writer.writeEndElement();
final XdmSequenceIterator iterator = writer.getDocumentNode().axisIterator(Axis.CHILD);
return iterator.next().getUnderlyingValue();
} catch (SaxonApiException | XMLStreamException e) {
logger.error(e, e);
throw new XPathException("Failed to create element: " + e.getMessage());
}
}
示例14: doProcess2
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
@Override
protected boolean doProcess2(Record inputRecord, InputStream stream) throws SaxonApiException, XMLStreamException {
incrementNumRecords();
for (Fragment fragment : fragments) {
Record template = inputRecord.copy();
removeAttachments(template);
XdmNode document = parseXmlDocument(stream);
LOG.trace("XQuery input document: {}", document);
XQueryEvaluator evaluator = fragment.xQueryEvaluator;
evaluator.setContextItem(document);
int i = 0;
for (XdmItem item : evaluator) {
i++;
if (LOG.isTraceEnabled()) {
LOG.trace("XQuery result sequence item #{} is of class: {} with value: {}", new Object[] { i,
item.getUnderlyingValue().getClass().getName(), item });
}
if (item.isAtomicValue()) {
LOG.debug("Ignoring atomic value in result sequence: {}", item);
continue;
}
XdmNode node = (XdmNode) item;
Record outputRecord = template.copy();
boolean isNonEmpty = addRecordValues(node, Axis.SELF, XdmNodeKind.ATTRIBUTE, outputRecord);
isNonEmpty = addRecordValues(node, Axis.ATTRIBUTE, XdmNodeKind.ATTRIBUTE, outputRecord) || isNonEmpty;
isNonEmpty = addRecordValues(node, Axis.CHILD, XdmNodeKind.ELEMENT, outputRecord) || isNonEmpty;
if (isNonEmpty) { // pass record to next command in chain
if (!getChild().process(outputRecord)) {
return false;
}
}
}
}
return true;
}
示例15: addRecordValues
import net.sf.saxon.s9api.Axis; //导入依赖的package包/类
protected boolean addRecordValues(XdmNode node, Axis axis, XdmNodeKind nodeTest, Record record) {
boolean isEmpty = true;
XdmSequenceIterator iter = node.axisIterator(axis);
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
if (child.getNodeKind() == nodeTest) {
String strValue = child.getStringValue();
if (strValue.length() > 0) {
record.put(child.getNodeName().getLocalName(), strValue);
isEmpty = false;
}
}
}
return !isEmpty;
}