当前位置: 首页>>代码示例>>Java>>正文


Java XdmNode类代码示例

本文整理汇总了Java中net.sf.saxon.s9api.XdmNode的典型用法代码示例。如果您正苦于以下问题:Java XdmNode类的具体用法?Java XdmNode怎么用?Java XdmNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XdmNode类属于net.sf.saxon.s9api包,在下文中一共展示了XdmNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildJavaStep

import net.sf.saxon.s9api.XdmNode; //导入依赖的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;
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:10,代码来源:ConfigUtil.java

示例2: buildContent

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
protected String buildContent(XdmDocument contentDoc, boolean canonical) throws Exception {
    DocumentImpl contentDocInfo = contentDoc.getUnderlyingNode();
    Source contentSrc;
    XmlEncodeOptions contentEncodeOpts = this.xmlCodec.getDefaultEncodeOptions().clone();

    if (canonical) {
        for (SdcctXpathExecutable canonicalRemoveXpathExec : this.resourceMetadata.getCanonicalRemoveXpathExecutables()) {
            for (XdmNode canonicalRemoveNode : canonicalRemoveXpathExec.load(new DynamicXpathOptionsImpl().setContextItem(contentDocInfo))
                .evaluateNodes()) {
                ((MutableNodeInfo) canonicalRemoveNode.getUnderlyingNode()).delete();
            }
        }

        contentEncodeOpts.getParseOptions().setStripSpace(Whitespace.ALL);

        contentSrc = new ByteArraySource(Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS)
            .canonicalizeSubtree(NodeOverNodeInfo.wrap(contentDoc.getUnderlyingNode())), contentDoc.getPublicId(), contentDoc.getSystemId());
    } else {
        contentSrc = contentDoc.getUnderlyingNode();
    }

    return new String(this.xmlCodec.encode(contentSrc, contentEncodeOpts), StandardCharsets.UTF_8);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:24,代码来源:AbstractSdcctResourceRegistry.java

示例3: buildXslt

import net.sf.saxon.s9api.XdmNode; //导入依赖的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;
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:17,代码来源:ConfigUtil.java

示例4: buildFile

import net.sf.saxon.s9api.XdmNode; //导入依赖的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;
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:26,代码来源:ConfigUtil.java

示例5: testAddAttribute

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
@Test
public void testAddAttribute() throws Exception {
    GauloisPipe piper = new GauloisPipe(configFactory);
    ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "./src/test/resources/AddAttributeJavaStep.xml");
    Config config = cu.buildConfig(emptyInputParams);
    config.verify();
    piper.setConfig(config);
    piper.setInstanceName("ADD_ATTRIBUTE");
    piper.launch();
    Processor proc = new Processor(configFactory.getConfiguration());
    File expect = new File("target/generated-test-files/source-identity-addAttribute.xml");
    XdmNode document = proc.newDocumentBuilder().build(expect);
    XPathExecutable exec = proc.newXPathCompiler().compile("//*[@test]");
    XPathSelector selector = exec.load();
    selector.setContextItem((XdmItem)document);
    XdmValue result = selector.evaluate();
    assertTrue(result.size()>0);
    expect.delete();
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:20,代码来源:GauloisPipeTest.java

示例6: testXdmValueToXsl

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
@Test
public void testXdmValueToXsl() throws InvalidSyntaxException, SaxonApiException, URISyntaxException, IOException, ValidationException  {
    GauloisPipe piper = new GauloisPipe(configFactory);
    ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "./src/test/resources/paramDate.xml");
    HashMap<QName,ParameterValue> params = new HashMap<>();
    QName qnDate = new QName("date");
    // to get a date XdmValue from saxon, we must be brilliants !
    Processor proc = new Processor(configFactory.getConfiguration());
    XQueryEvaluator ev = proc.newXQueryCompiler().compile("current-dateTime()").load();
    XdmItem item = ev.evaluateSingle();
    params.put(qnDate, new ParameterValue(qnDate, item, factory.getDatatype(new QName("xs","http://www.w3.org/2001/XMLSchema","dateTime"))));
    Config config = cu.buildConfig(params);
    config.verify();
    piper.setConfig(config);
    piper.setInstanceName("XDM_VALUE_TO_XSL");
    piper.launch();
    File expect = new File("target/generated-test-files/date-output.xml");
    XdmNode document = proc.newDocumentBuilder().build(expect);
    XPathExecutable exec = proc.newXPathCompiler().compile("/date");
    XPathSelector selector = exec.load();
    selector.setContextItem((XdmItem)document);
    XdmValue result = selector.evaluate();
    assertTrue(result.size()>0);
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:25,代码来源:GauloisPipeTest.java

示例7: testStaticBaseUri

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
public void testStaticBaseUri() throws InvalidSyntaxException, SaxonApiException, URISyntaxException, IOException, ValidationException {
    File expect = new File("target/generated-test-file/static-base-uri-ret.xml");
    if(expect.exists()) expect.delete();
    GauloisPipe piper = new GauloisPipe(configFactory);
    ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "./src/test/resources/static-base-uri.xml");
    HashMap<QName,ParameterValue> params = new HashMap<>();
    Config config = cu.buildConfig(params);
    config.verify();
    piper.setConfig(config);
    piper.setInstanceName("STATIC-BASE-URI");
    piper.launch();
    assertTrue(expect.exists());
    Processor proc = new Processor(configFactory.getConfiguration());
    XdmNode document = proc.newDocumentBuilder().build(expect);
    XPathExecutable exec = proc.newXPathCompiler().compile("/ret/*/text()");
    XPathSelector selector = exec.load();
    selector.setContextItem((XdmItem)document);
    XdmValue result = selector.evaluate();
    String staticBaseUri = result.itemAt(0).getStringValue();
    String gpStaticBaseUri = result.itemAt(1).getStringValue();
    assertTrue("gp:staticBaseUri does not ends with target/classes/xsl/static-base-uri-ret.xml", gpStaticBaseUri.endsWith("target/classes/xsl/static-base-uri-ret.xml"));
    expect.delete();
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:24,代码来源:GauloisPipeTest.java

示例8: namespaceProcess

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
private void namespaceProcess(final XdmNode node) {
	final NodeInfo inode = node.getUnderlyingNode();
	final NamespaceBinding[] inscopeNS = inode.getDeclaredNamespaces(null);
	// NamespaceIterator.getInScopeNamespaceCodes(inode);

	if (inscopeNS.length > 0) {
		for (final NamespaceBinding ns : inscopeNS) {
			final String pfx = ns.getPrefix();
			final String uri = ns.getURI();
			this.doc.append(
					AQuiXEvent.getNamespace(QuiXCharStream.fromSequence(pfx), QuiXCharStream.fromSequence(uri)));
		}
	}

	// Careful, we're messing with the namespace bindings
	// Make sure the nameCode is right...
	// int nameCode = inode.getNameCode();
	// int typeCode = inode.getTypeAnnotation() & NamePool.FP_MASK;
	// String pfx = pool.getPrefix(nameCode);
	// String uri = pool.getURI(nameCode);

	// if (excludeDefault && "".equals(pfx) && !usesDefaultNS) {
	// nameCode = pool.allocate("", "", pool.getLocalName(nameCode));
	// }

	// tree.addStartElement(nameCode, typeCode, newNS);
	// tree.addAttributes(node);

}
 
开发者ID:Innovimax-SARL,项目名称:QuiXDM,代码行数:30,代码来源:AXdmNode2QuiXEventStreamConverter.java

示例9: nextFile

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
private void nextFile() {
    count += 1;
    if (count >= limit) {
        tree.addEndElement();
        tree.endDocument();

        XdmNode out = tree.getResult();
        result.write(out);

        tree = new TreeWriter(runtime);
        tree.startDocument(step.getNode().getBaseURI());
        tree.addStartElement(sem_triples);
        tree.startContent();

        count = 0;
    }
}
 
开发者ID:ndw,项目名称:xmlcalabash1-rdf,代码行数:18,代码来源:RDFa.java

示例10: resolveToNode

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
public NodeInfo resolveToNode(List<Parameter> frameworkParameters) throws XPathException, TempContextException {
	//logger.info("resolveToNode: " + getScriptName());
	final NodeInfo 	resolvedNode 	= resolve(frameworkParameters);
	NodeInfo 		resolvedElement = resolvedNode.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
	//logger.info("needsReparse: " + XsltConref.needsReparse(resolvedElement));
	if (XsltConref.needsReparse(resolvedElement)) {
		final String 	serialized 		= SaxonNodeWrapper.serializeNode(resolvedNode);
		try {
			//logger.info("reparsing...");
			//logger.info(serialized);
			final XdmNode 	reparsedNode 	= xsltConrefCache.getDocumentBuilder().buildFromString(serialized, true);
			
			resolvedElement = reparsedNode.getUnderlyingNode().iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
			//logger.info("---");
			//logger.info(SaxonNodeWrapper.serializeNode(reparsedElement));
		} catch (SaxonApiException e) {
			logger.info("------");
			logger.info("serialized node:");
			logger.info(serialized);
			logger.info("------");
			throw new XPathException("Failed to reparse resolved xslt-conref ('" + getScriptName() + "'): " + e.getMessage());
		}
	} 
	resolvedElement.setSystemId(node.getBaseUrl().toString());
	return resolvedElement;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:27,代码来源:XsltConref.java

示例11: extractString

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
private String extractString(SaxonNodeWrapper node, String xslUrl) {
	try {
		final XsltExecutable 	executable 		= bookCache.getExtractTransformerCache().getExecutable(new URL(bookCache.getDitaOtUrl(), xslUrl));
		final XsltTransformer 	xsltTransformer = executable.load();
		xsltTransformer.setInitialContextNode(new XdmNode(node.getNodeInfo()));
		
		final XdmDestination destination = new XdmDestination();
		xsltTransformer.setDestination(destination);
		xsltTransformer.transform();
		
		return destination.getXdmNode().getStringValue();
	} catch (Exception e) {
		logger.error(e, e);
		return "<ERR>";
	}
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:17,代码来源:FileCache.java

示例12: checkResult

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
private void checkResult(final XsltConref xsltConref, final NodeInfo resolvedElement) {
	
	// check for missing class attribute
	try {
		final XdmNode		context	= new XdmNode(resolvedElement);
		final XPathSelector sel		= otResolver.getXPathCache().getXPathSelector(MISSING_CLASS_XPATH, context);
		final XdmItem item = sel.evaluateSingle();
		if (item != null) {
			String name;
			if (item instanceof XdmNode) {
				name = "node '" + ((XdmNode)item).getNodeName() + "'";
			} else {
				name = "item '" + item.getStringValue() + "'";
			}
			otResolver.getOtLogger().error("[DOT-DITA-SEMIA][ERROR] Missing class attribute in resolved xslt-conref '" + xsltConref.getScriptName() + "'. E.g. on " + name + ".");
		}
		
	} catch (SaxonApiException | XPathException e) {
		logger.error(e.getMessage(), e);
	}
	
	
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:24,代码来源:ResolveXsltConrefCall.java

示例13: applyXpath

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
public static List<String> applyXpath(String xml, String xpathString) {
  List<String> result = new ArrayList<>();
  try {
    Processor proc = new Processor(false);
    XPathCompiler xpath = proc.newXPathCompiler();
    DocumentBuilder builder = proc.newDocumentBuilder();

    // Load the XML document.
    StringReader reader = new StringReader(xml);
    XdmNode doc = builder.build(new StreamSource(reader));

    // Compile the xpath
    XPathSelector selector = xpath.compile(xpathString).load();
    selector.setContextItem(doc);

    // Evaluate the expression.
    XdmValue nodes = selector.evaluate();

    for (XdmItem item : nodes) {
      result.add(item.toString());
    }

  } catch (Exception e) {
    LOGGER.error("Error applying XPath", e);
  }
  return result;
}
 
开发者ID:keeps,项目名称:roda-in,代码行数:28,代码来源:TemplateUtils.java

示例14: buildNumberResourceParam

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
@Override
protected void buildNumberResourceParam(String type, Map<MultiKey<Serializable>, ResourceParam<?>> resourceParams, String name,
    ResourceParamMetadata resourceParamMetadata, XdmItem item, FhirResource entity) throws Exception {
    Object itemValue = this.decodeNode(((XdmNode) item));
    BigDecimal value = null;

    if (itemValue instanceof DecimalType) {
        value = ((DecimalType) itemValue).getValue();
    } else if (itemValue instanceof IntegerType) {
        value = BigDecimal.valueOf(((IntegerType) itemValue).getValue());
    } else if (itemValue instanceof PositiveIntType) {
        value = new BigDecimal(((PositiveIntType) itemValue).getValue());
    } else if (itemValue instanceof UnsignedIntType) {
        value = new BigDecimal(((UnsignedIntType) itemValue).getValue());
    } else {
        super.buildNumberResourceParam(type, resourceParams, name, resourceParamMetadata, item, entity);
    }

    resourceParams.put(new MultiKey<>(name, value), new NumberResourceParamImpl(entity, name, value));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:21,代码来源:FhirResourceParamProcessorImpl.java

示例15: buildStringResourceParam

import net.sf.saxon.s9api.XdmNode; //导入依赖的package包/类
@Override
protected void buildStringResourceParam(String type, Map<MultiKey<Serializable>, ResourceParam<?>> resourceParams, String name,
    ResourceParamMetadata resourceParamMetadata, XdmItem item, FhirResource entity) throws Exception {
    Object itemValue = this.decodeNode(((XdmNode) item));
    String value = null;

    if (itemValue instanceof CodeType) {
        value = ((CodeType) itemValue).getValue();
    } else if (itemValue instanceof IdType) {
        value = ((IdType) itemValue).getValue();
    } else if (itemValue instanceof StringType) {
        value = ((StringType) itemValue).getValue();
    } else {
        super.buildStringResourceParam(type, resourceParams, name, resourceParamMetadata, item, entity);
    }

    resourceParams.put(new MultiKey<>(name, value), new StringResourceParamImpl(entity, name, value));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:19,代码来源:FhirResourceParamProcessorImpl.java


注:本文中的net.sf.saxon.s9api.XdmNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。