javax.xml.transform.Source.setSystemId()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中javax.xml.transform.Source.setSystemId()方法的一些代码示例,展示了Source.setSystemId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Source.setSystemId()方法的具体详情如下:
包路径:javax.xml.transform.Source
类名称:Source
方法名:setSystemId

Source.setSystemId介绍

[英]Set the system identifier for this Source.

The system identifier is optional if the source does not get its data from a URL, but it may still be useful to provide one. The application can use a system identifier, for example, to resolve relative URIs and to include in error messages and warnings.
[中]设置此源的系统标识符。
如果源没有从URL获取数据,那么系统标识符是可选的,但提供一个系统标识符可能仍然有用。例如,应用程序可以使用系统标识符来解析相对URI,并将其包含在错误消息和警告中。

代码示例

代码示例来源:origin: xalan/xalan

/**
 * Implements javax.xml.transform.Source.setSystemId()
 * Set the system identifier for this Source. 
 * This Source can get its input either directly from a file (in this case
 * it will instanciate and use a JAXP parser) or it can receive it through
 * ContentHandler/LexicalHandler interfaces.
 * @param systemId The system Id for this Source
 */
public void setSystemId(String systemId) {
  _systemId = systemId;
  if (_source != null) {
    _source.setSystemId(systemId);
  }
}

代码示例来源:origin: org.apache.ant/ant

private Source getSource(final InputStream is, final Resource resource)
  throws ParserConfigurationException, SAXException {
  // todo: is this comment still relevant ??
  // FIXME: need to use a SAXSource as the source for the transform
  // so we can plug in our own entity resolver
  Source src = null;
  if (entityResolver != null) {
    if (getFactory().getFeature(SAXSource.FEATURE)) {
      final SAXParserFactory spFactory = SAXParserFactory.newInstance();
      spFactory.setNamespaceAware(true);
      final XMLReader reader = spFactory.newSAXParser().getXMLReader();
      reader.setEntityResolver(entityResolver);
      src = new SAXSource(reader, new InputSource(is));
    } else {
      throw new IllegalStateException("xcatalog specified, but "
        + "parser doesn't support SAX");
    }
  } else {
    // WARN: Don't use the StreamSource(File) ctor. It won't work with
    // xalan prior to 2.2 because of systemid bugs.
    src = new StreamSource(is);
  }
  // The line below is a hack: the system id must an URI, but it is not
  // cleat to get the URI of an resource, so just set the name of the
  // resource as a system id
  src.setSystemId(resourceToURI(resource));
  return src;
}

代码示例来源:origin: org.apache.ant/ant

src.setSystemId(JAXPUtils.getSystemId(infile));
return src;

代码示例来源:origin: xalan/xalan

/**
 * This class wraps an ErrorListener into a MessageHandler in order to
 * capture messages reported via xsl:message.
 */
static class MessageHandler 
    extends org.apache.xalan.xsltc.runtime.MessageHandler 
{
private ErrorListener _errorListener;
 public MessageHandler(ErrorListener errorListener) {
  _errorListener = errorListener;
}
 public void displayMessage(String msg) {
  if(_errorListener == null) {
  System.err.println(msg); 
  }
  else {
  try {
    _errorListener.warning(new TransformerException(msg));
  }
  catch (TransformerException e) {
    // ignored 
  }
  }
}
}

代码示例来源:origin: robovm/robovm

source.setSystemId(systemID);

代码示例来源:origin: plutext/docx4j

source.setSystemId(systemID);

代码示例来源:origin: xalan/xalan

source.setSystemId(systemID);

代码示例来源:origin: robovm/robovm

source.setSystemId(systemID);

代码示例来源:origin: xalan/xalan

source.setSystemId(systemID);

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Set the System ID. This sets the System Id on the underlying Source object.
 * @param id the System ID. This provides a base URI for the document, and also the result
 * of the document-uri() function
 * @since 8.8
 */
public void setSystemId(String id) {
  source.setSystemId(id);
}

代码示例来源:origin: org.xmlunit/xmlunit-core

void setSystemId(String id) {
    if (id != null) {
      source.setSystemId(id);
    }
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Set the System ID. This sets the System Id on the underlying Source object.
 * @param id the System ID. This provides a base URI for the document, and also the result
 * of the document-uri() function
 * @since 8.8
 */
public void setSystemId(String id) {
  source.setSystemId(id);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
 * Implements javax.xml.transform.Source.setSystemId()
 * Set the system identifier for this Source. 
 * This Source can get its input either directly from a file (in this case
 * it will instanciate and use a JAXP parser) or it can receive it through
 * ContentHandler/LexicalHandler interfaces.
 * @param systemId The system Id for this Source
 */
public void setSystemId(String systemId) {
  _systemId = systemId;
  if (_source != null) {
    _source.setSystemId(systemId);
  }
}

代码示例来源:origin: stackoverflow.com

// construct a Source that reads from an InputStream
Source mySrc = new StreamSource(anInputStream);
// specify a system ID (a String) so the 
// Source can resolve relative URLs
// that are encountered in XSLT stylesheets
mySrc.setSystemId(aSystemId);

代码示例来源:origin: stackoverflow.com

// construct a Source that reads from an InputStream
Source mySrc = new StreamSource(anInputStream);
// specify a system ID (a String) so the 
// Source can resolve relative URLs
// that are encountered in XSLT stylesheets
mySrc.setSystemId(aSystemId);

代码示例来源:origin: DSpace/DSpace

@Override
  public Transformer getTransformer(String path) throws IOException,
    TransformerConfigurationException {
    // construct a Source that reads from an InputStream
    Source mySrc = new StreamSource(getResource(path));
    // specify a system ID (the path to the XSLT-file on the filesystem)
    // so the Source can resolve relative URLs that are encountered in
    // XSLT-files (like <xsl:import href="utils.xsl"/>)
    String systemId = basePath + "/" + path;
    mySrc.setSystemId(systemId);
    return transformerFactory.newTransformer(mySrc);
  }
}

代码示例来源:origin: stackoverflow.com

Source source = new DOMSource(doc);

URI uri = new File("infilename.xml").toURI();
source.setSystemId(uri.toString());

DefaultHandler handler = new MyHandler();
SAXResult result = new SAXResult(handler);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);

代码示例来源:origin: Evolveum/midpoint

public Source getSource() {
  Source source = null;
  if (canInputStream()) {
    InputStream inputStream = openInputStream();
    // Return stream source as a first option. It is less effcient,
    // but it provides information about line numbers
    source = new StreamSource(inputStream);
  } else {
    source = new DOMSource(node);
  }
  source.setSystemId(path);
  return source;
}

代码示例来源:origin: org.custommonkey.xmlunit/com.springsource.org.custommonkey.xmlunit

/**
 * Ensure that the source has a systemId
 * @param source
 */
private void provideSystemIdIfRequired(Source source) {
  if (source!=null && (source.getSystemId() == null
             || source.getSystemId().length() == 0)) {
    source.setSystemId(getDefaultSystemId());
  }
}

代码示例来源:origin: org.xmlunit/xmlunit-legacy

/**
 * Ensure that the source has a systemId
 * @param source
 */
private void provideSystemIdIfRequired(Source source) {
  if (source!=null && (source.getSystemId() == null
             || source.getSystemId().length() == 0)) {
    source.setSystemId(getDefaultSystemId());
  }
}

相关文章