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


Java XPathContext.getConfiguration方法代码示例

本文整理汇总了Java中net.sf.saxon.expr.XPathContext.getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.getConfiguration方法的具体用法?Java XPathContext.getConfiguration怎么用?Java XPathContext.getConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.saxon.expr.XPathContext的用法示例。


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

示例1: call

import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {                     
  try {
    String json = ((StringValue) arguments[0].head()).getStringValue();
    if (StringUtils.isBlank(json)) {
      return EmptySequence.getInstance();
    }        
    XMLInputFactory factory = new JsonXMLInputFactory();                
    XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(json));        
    StAXSource source = new StAXSource(reader);        
    Configuration config = context.getConfiguration();        
    PipelineConfiguration pipe = config.makePipelineConfiguration();
    pipe.getParseOptions().getParserFeatures().remove("http://apache.org/xml/features/xinclude");        
    TinyBuilder builder = new TinyBuilder(pipe);        
    SerializerFactory sf = config.getSerializerFactory();
    Receiver receiver = sf.getReceiver(builder, pipe, new Properties());               
    NamespaceReducer reducer = new NamespaceReducer(receiver);
    ParseOptions options = pipe.getParseOptions();
    options.setContinueAfterValidationErrors(true);
    Sender.send(source, reducer, options);                             
    return builder.getCurrentRoot();                
  } catch (Exception e) {
    throw new XPathException("Error parsing JSON string", e);
  }                    
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:26,代码来源:ParseJSON.java

示例2: call

import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {

        	final Processor 		processor 	= new Processor(context.getConfiguration());
			final DocumentBuilder 	builder 	= processor.newDocumentBuilder();
			
			try {
				BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();

				writer.writeStartElement("test1");
				writer.writeCharacters("text1");
				writer.writeEndElement();
				
				writer.writeStartElement("test2");
				writer.writeCharacters("text2");
				writer.writeEndElement();
				
				return writer.getDocumentNode().getUnderlyingValue();
				
			} catch (SaxonApiException | XMLStreamException e) {
				logger.error(e, e);
				throw new XPathException("Failed to create return value: " + e.getMessage());
			}
        }
 
开发者ID:dita-semia,项目名称:XsltGui,代码行数:24,代码来源:GuiTest.java

示例3: createKeyTypeElement

import net.sf.saxon.expr.XPathContext; //导入方法依赖的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());
		}
	}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:27,代码来源:GetKeyTypeDefCall.java

示例4: call

import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
	final Item keyDefItem = arguments[0].head();
	if (keyDefItem != null) {
		final KeyDefInterface keyDef = DitaSemiaOtResolver.getKeyDefFromItem(keyDefItem);
		//logger.info(keyDef + ": " + keyDef.isFilteredKey());
		final FilterAttrSet 			set = keyDef.getKeyFilterAttrSet();
		final Map<String, Set<String>>	map = (set == null) ? null : set.getMap();
		
		if (map != null) {
			final Processor 				processor 	= new Processor(context.getConfiguration());
			final DocumentBuilder 			builder 	= processor.newDocumentBuilder();
			
			try {
				BuildingStreamWriterImpl 	writer 		= builder.newBuildingStreamWriter();
				writer.writeStartElement("Container");
				for (Entry<String, Set<String>> entry : map.entrySet()) {
					writer.writeAttribute(entry.getKey(), String.join(" ", entry.getValue()));
				}
				writer.writeEndElement();
				
				XdmSequenceIterator iterator = writer.getDocumentNode().axisIterator(Axis.CHILD);
				return ((XdmNode)iterator.next()).getUnderlyingNode();
				
			} catch (SaxonApiException | XMLStreamException e) {
				throw new XPathException("Failed to create result-node", e);
			}
		}		
	}
	return EmptySequence.getInstance();
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:32,代码来源:GetKeyFilterAttrCall.java


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