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


Java Whitespace类代码示例

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


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

示例1: buildContent

import net.sf.saxon.value.Whitespace; //导入依赖的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

示例2: postProcessExistingResponse

import net.sf.saxon.value.Whitespace; //导入依赖的package包/类
@Nullable
private Response postProcessExistingResponse(@Nullable Response resp) {
    Object respEntity;

    if ((resp == null) || !((respEntity = resp.getEntity()) instanceof DOMSource)) {
        return resp;
    }

    DOMSource respSrc = ((DOMSource) respEntity);

    AugmentedSource augmentedRespSrc = AugmentedSource.makeAugmentedSource(respSrc);
    augmentedRespSrc.setStripSpace(Whitespace.ALL);
    augmentedRespSrc.addFilter(CommentStripper::new);

    Document respDoc = DOMUtils.createDocument();

    try {
        this.displayXmlSerializer.serializeToResult(augmentedRespSrc, new DOMResult(respDoc));
    } catch (SaxonApiException e) {
        throw new SaxonApiUncheckedException(e);
    }

    respSrc.setNode(respDoc);

    return resp;
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:27,代码来源:CrigttWadlGenerator.java

示例3: call

import net.sf.saxon.value.Whitespace; //导入依赖的package包/类
@Override
public ZeroOrOne<NodeInfo> call(XPathContext context, Sequence[] arguments) throws XPathException {
  String xml = ((StringValue) arguments[0].head()).getStringValue();
  try {                
    Controller controller = context.getController();        
    if (controller == null) {
      throw new XPathException("parse() function is not available in this environment");
    }        
    Configuration configuration = controller.getConfiguration();
    StringReader sr = new StringReader(xml);
    InputSource is = new InputSource(sr);                        
    //is.setSystemId(baseURI);
    Source source = new SAXSource(is);
    //source.setSystemId(baseURI);

    Builder b = TreeModel.TINY_TREE.makeBuilder(controller.makePipelineConfiguration());
    Receiver s = b;
    ParseOptions options = new ParseOptions();
    options.setStripSpace(Whitespace.XSLT);
    options.setErrorListener(context.getConfiguration().getErrorListener());

    if (controller.getExecutable().stripsInputTypeAnnotations()) {
      s = configuration.getAnnotationStripper(s);
    }
    s.setPipelineConfiguration(b.getPipelineConfiguration());

    Sender.send(source, s, options);

    TinyDocumentImpl node = (TinyDocumentImpl) b.getCurrentRoot();
    // node.setBaseURI(baseURI);
    node.setSystemId(null);
    b.reset();
    return new ZeroOrOne<NodeInfo>((NodeInfo)node);
  } catch (XPathException err) {
    throw new XPathException("First argument to parse is not a well-formed and namespace-well-formed XML document. XML parser reported: " + err.getMessage(), "FODC0006");
  }

}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:39,代码来源:Parse.java

示例4: renderInternal

import net.sf.saxon.value.Whitespace; //导入依赖的package包/类
@Override
protected byte[] renderInternal(ValidatorResponse resp, Map<String, Object> opts) throws Exception {
    ByteArrayResult result = new ByteArrayResult();

    this.renderInternal(resp, opts, new XMLStreamWriterDestination(this.xmlOutFactory.createXMLStreamWriter(result)));

    AugmentedSource augmentedSrc = AugmentedSource.makeAugmentedSource(new ByteArraySource(result.getBytes()));
    augmentedSrc.setStripSpace(Whitespace.ALL);
    augmentedSrc.addFilter(NormalizeWhitespaceFilter::new);

    return (CrigttOptionUtils.toBoolean(opts.get(ValidatorRenderOptions.FORMAT_NAME), ((Boolean) this.defaultOpts.get(ValidatorRenderOptions.FORMAT_NAME)))
        ? this.displaySerializer : this.serializer).serializeToBytes(augmentedSrc);
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:14,代码来源:HtmlValidatorRendererImpl.java

示例5: getStringFromTransform

import net.sf.saxon.value.Whitespace; //导入依赖的package包/类
/**
 * 功能: 从转化中获取String
 * 
 * @param document
 * @return
 */
public static String getStringFromTransform(String xsltPath, String myTableXml, Map<String, Object> mAttribute) {
	String result = "";
	xsltPath = RmXmlHelper.formatToUrl(xsltPath);
	myTableXml = RmXmlHelper.formatToUrl(myTableXml);
	ByteArrayOutputStream bytesStream = new ByteArrayOutputStream();
	BufferedOutputStream outer = new BufferedOutputStream(bytesStream);
	Transformer transformer = null;
	try {
		Configuration config = new Configuration();
		config.setStripsAllWhiteSpace(true);
		config.setStripsWhiteSpace(Whitespace.ALL);
		TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl(config);
		StreamSource ss = new StreamSource(xsltPath);
		Templates pss = factory.newTemplates(ss);
		transformer = pss.newTransformer();
		if(mAttribute != null) {
			for(String key : mAttribute.keySet()) {
				transformer.setParameter(key, mAttribute.get(key));
			}
		}
		transformer.transform(new StreamSource(myTableXml), new StreamResult(outer));
		result = bytesStream.toString(RmBaseConfig.getSingleton().getDefaultEncode());
	} catch (Throwable e) {
		e.printStackTrace();
		throw new RuntimeException(e); 
	} finally {
		try {
			if (outer != null) {
				outer.close();
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
	return result;
}
 
开发者ID:quickbundle,项目名称:qb-core,代码行数:43,代码来源:RmTransform.java

示例6: createNodeFromNodeInfo

import net.sf.saxon.value.Whitespace; //导入依赖的package包/类
public static Node createNodeFromNodeInfo(NodeInfo nodeInfo, 
    Document doc, DiffXML.WhitespaceStrippingPolicy whitespaceHandling) {
  Node node = null;
  switch (nodeInfo.getNodeKind()) {
  case Type.TEXT:
    String content = nodeInfo.getStringValue();
    boolean isWhitespace = Whitespace.isWhite(content);
    if (isWhitespace && whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
      break;
    }
    node = doc.createTextNode(content);
    break;
  case Type.WHITESPACE_TEXT:
    content = nodeInfo.getStringValue();
    if (whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
      node = doc.createTextNode(content);
    }
    break;
  case Type.ELEMENT:
    if (nodeInfo.getURI().equals("")) {
      node = doc.createElement(nodeInfo.getLocalPart());
    } else {
      node = doc.createElementNS(nodeInfo.getURI(), nodeInfo.getLocalPart());
    }
    
    AxisIterator namespaces = nodeInfo.iterateAxis(AxisInfo.NAMESPACE);
    NodeInfo ns;
    while ((ns = namespaces.next()) != null) {
      String localPart = ns.getLocalPart();
      String qualifiedName;
      if (localPart.equals(""))
        qualifiedName = "xmlns";
      else
        qualifiedName = "xmlns:" + localPart;
      ((Element) node).setAttributeNS("http://www.w3.org/2000/xmlns/", qualifiedName, ns.getStringValue());
    }
    
    AxisIterator attrs = nodeInfo.iterateAxis(AxisInfo.ATTRIBUTE);
    NodeInfo attr;
    while ((attr = attrs.next()) != null) {
      if (attr.getURI().equals("")) {
        ((Element) node).setAttribute(attr.getLocalPart(), attr.getStringValue());
      } else if (attr.getURI().equals(Definitions.NAMESPACEURI_DELTAXML) && attr.getLocalPart().equals("whitespace")) {
        String value = attr.getStringValue();
        try {
          whitespaceHandling = WhitespaceStrippingPolicy.valueOf(value);
        } catch (Exception e) {
          throw new XSLWebException("Value for whitespace handling not supported: \"" + value + "\"");
        }
      } else {
        ((Element) node).setAttributeNS(attr.getURI(), attr.getPrefix() + ":" + attr.getLocalPart(), attr.getStringValue());
      }
    }
    
    break;
  /*
  case Type.COMMENT:
    treeNode = new CommentNode(nodeInfo.getStringValue());
    break;
  case Type.PROCESSING_INSTRUCTION:
    treeNode = new ProcessingInstructionNode(nodeInfo.getStringValue()); // TODO
    break;
  */
  }
  
  if (node != null && nodeInfo.hasChildNodes()) {
    AxisIterator childs = nodeInfo.iterateAxis(AxisInfo.CHILD);
    NodeInfo childNodeInfo;
    while ((childNodeInfo = childs.next()) != null) {
      Node newNode = createNodeFromNodeInfo(childNodeInfo, doc, whitespaceHandling);
      if (newNode != null) {
        node.appendChild(newNode);
      }
    }
  }
  
  return node;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:79,代码来源:DiffUtils.java


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