本文整理汇总了Java中net.sf.saxon.s9api.QName类的典型用法代码示例。如果您正苦于以下问题:Java QName类的具体用法?Java QName怎么用?Java QName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QName类属于net.sf.saxon.s9api包,在下文中一共展示了QName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildJavaStep
import net.sf.saxon.s9api.QName; //导入依赖的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: setVariables
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
@Override
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public T setVariables(@Nullable Map<QName, XdmValue> vars) {
this.vars.clear();
if (!MapUtils.isEmpty(vars)) {
this.vars.putAll(vars);
}
return ((T) this);
}
示例3: processParametersReplacement
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
/**
* Replaces the parameters in string
* @param initialValue The String to change parameters in
* @param parameters The parameters values
* @return The initialValue with all parameters replaced
*/
public static Object processParametersReplacement(Object initialValue, final HashMap<QName,ParameterValue> parameters) {
if(initialValue instanceof String) {
String ret = initialValue.toString();
if(ret.contains("$[")) {
for(ParameterValue pv: parameters.values()) {
if(pv.getValue() instanceof String) {
try {
// issue #14
ret = ret.replaceAll("\\$\\["+pv.getKey()+"\\]", Matcher.quoteReplacement(pv.getValue().toString()));
} catch(java.lang.IllegalArgumentException ex) {
LOGGER.error("while replacing "+pv.getKey()+" -> "+pv.getValue(),ex);
throw ex;
}
}
if(!ret.contains("$[")) break;
}
}
return ret;
} else {
return initialValue;
}
}
示例4: buildXslt
import net.sf.saxon.s9api.QName; //导入依赖的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;
}
示例5: buildFile
import net.sf.saxon.s9api.QName; //导入依赖的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;
}
示例6: getDatatype
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
public Datatype getDatatype(QName qn) throws ValidationException {
Datatype ret = constructed.get(qn);
if(ret==null) {
ret = constructDatatype(qn);
constructed.put(qn, ret);
}
return ret;
}
示例7: testXdmValueToXsl
import net.sf.saxon.s9api.QName; //导入依赖的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);
}
示例8: testStaticBaseUri
import net.sf.saxon.s9api.QName; //导入依赖的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();
}
示例9: testSourceFolderContent
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
@Test
public void testSourceFolderContent() throws InvalidSyntaxException, SaxonApiException, MalformedURLException {
GauloisPipe piper = new GauloisPipe(configFactory);
ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "src/test/resources/folderContentRelative.xml");
Config config = cu.buildConfig(emptyInputParams);
assertTrue("relative path in source folder fails",config.getSources().getFiles().size()>=34);
cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "cp:/folderContentAbsUri.xml");
HashMap<QName, ParameterValue> params = new HashMap<>();
File currentPath = new File(System.getProperty("user.dir"));
// check if we are in the right directory
File test = new File(currentPath, "src/test/resources/folderContentAbsUri.xml");
if(!test.exists()) {
// probably, we are in parent folder
currentPath = new File(currentPath, "gaulois-pipe");
test = new File(currentPath, "src/test/resources/folderContentAbsUri.xml");
if(!test.exists()) {
fail("Unable to locate gaulois-pipe folder. Try moving to gaulois-pipe module folder.");
}
}
QName sourceQn = new QName("source");
params.put(sourceQn, new ParameterValue(sourceQn, currentPath.toURI().toURL().toExternalForm(), datatypeFactory.XS_STRING));
config = cu.buildConfig(params);
assertTrue("absolute URI in source folder fails", config.getSources().getFiles().size()>=34);
}
示例10: initialize
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
@BeforeClass
public static void initialize() throws ValidationException {
configFactory = new SaxonConfigurationFactory() {
Configuration config = Configuration.newConfiguration();
@Override
public Configuration getConfiguration() {
return config;
}
};
inputParams = new HashMap<>();
DatatypeFactory factory = DatatypeFactory.getInstance(configFactory.getConfiguration());
ParameterValue pv = new ParameterValue(new QName("p1"), "v1", factory.XS_STRING);
inputParams.put(pv.getKey(), pv);
pv = new ParameterValue(new QName("p2"), "v2", factory.XS_STRING);
inputParams.put(pv.getKey(), pv);
pv = new ParameterValue(new QName("p3"), "v3", factory.XS_STRING);
inputParams.put(pv.getKey(), pv);
pv = new ParameterValue(new QName("p4"), "v4", factory.XS_STRING);
inputParams.put(pv.getKey(), pv);
}
示例11: setCustomParameters
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
private void setCustomParameters(XsltTransformer xsltTransformer) throws XPathException {
//logger.info("setCustomParameters()");
final URL scriptUrl = getScriptUrl();
final XsltExecutable xsltExecutable = xsltConrefCache.getTransformerCache().getExecutable(scriptUrl, xsltConrefCache.getUriResolver());
final List<String> attrNameList = node.getAttributeNamesOfNamespace(NAMESPACE_PARAMETER_URI);
for (String attrName : attrNameList) {
//logger.info("attribute: " + attrName);
final QName paramName = new QName(attrName.replaceAll("(^[^\\{\\}]*:)|(^\\{.*\\})", ""));
final String paramValue = node.getAttribute(attrName, NAMESPACE_PARAMETER_URI);
//logger.info("set custom parameter: " + paramName + " = '" + paramValue + "'");
if (paramValue != null) {
if (xsltExecutable.getGlobalParameters().containsKey(paramName)) {
try {
xsltTransformer.setParameter(paramName, new XdmAtomicValue(EmbeddedXPathResolver.resolve(paramValue, node), ItemType.UNTYPED_ATOMIC));
//logger.info("parameters set. ");
} catch (SaxonApiException e) {
logger.error(e, e);
}
} else {
//logger.error("Parameter '" + paramName + "' not defined in script.");
}
}
}
}
示例12: initializeNodeInfo
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
private void initializeNodeInfo(@Nullable NodeInfo nodeInfo) {
if (nodeInfo == null) {
return;
}
int nodeKind = nodeInfo.getNodeKind();
NodeInfo elemInfo = null;
if (nodeKind == Type.ATTRIBUTE) {
this.attrQname = new QName(nodeInfo.getPrefix(), nodeInfo.getURI(), nodeInfo.getLocalPart());
elemInfo = nodeInfo.getParent();
} else if (nodeKind == Type.ELEMENT) {
elemInfo = nodeInfo;
}
if (elemInfo == null) {
return;
}
this.elemQname = new QName(elemInfo.getPrefix(), elemInfo.getURI(), elemInfo.getLocalPart());
}
示例13: initializeNode
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
private void initializeNode(@Nullable Node node) {
if (node == null) {
return;
}
Element elem = null;
if (node instanceof Attr) {
Attr attr = ((Attr) node);
this.attrQname = new QName(attr.getPrefix(), null, attr.getLocalName());
elem = attr.getOwnerElement();
} else if (node instanceof Element) {
elem = ((Element) node);
}
if (elem == null) {
return;
}
this.elemQname = new QName(elem.getPrefix(), null, elem.getLocalName());
}
示例14: initializeAttributeLocation
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
private void initializeAttributeLocation(@Nullable Object loc) {
if ((loc == null) || !(loc instanceof AttributeLocation)) {
return;
}
AttributeLocation attrLoc = ((AttributeLocation) loc);
StructuredQName nodeQname = attrLoc.getAttributeName();
if (nodeQname != null) {
this.attrQname = new QName(nodeQname);
}
if ((nodeQname = attrLoc.getElementName()) != null) {
this.elemQname = new QName(nodeQname);
}
}
示例15: convert
import net.sf.saxon.s9api.QName; //导入依赖的package包/类
@Nullable
@Override
public Object convert(Object src, TypeDescriptor srcType, TypeDescriptor targetType) {
if (!this.matches(srcType, targetType)) {
return null;
}
Class<?> srcObjType = srcType.getObjectType();
if (srcObjType.equals(Boolean.class)) {
return new XdmAtomicValue(((Boolean) src));
} else if (srcObjType.equals(Integer.class) || srcObjType.equals(Long.class)) {
return new XdmAtomicValue(((Long) src));
} else if (srcObjType.equals(Float.class)) {
return new XdmAtomicValue(((Float) src));
} else if (srcObjType.equals(Double.class)) {
return new XdmAtomicValue(((Double) src));
} else if (srcObjType.equals(QName.class)) {
return new XdmAtomicValue(((QName) src));
} else if (srcObjType.equals(URI.class)) {
return new XdmAtomicValue(((URI) src));
} else {
return new XdmAtomicValue(((String) src));
}
}