Java Code Examples for javax.xml.transform.Source#getSystemId()

The following examples show how to use javax.xml.transform.Source#getSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformerFactoryImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the base class name of the translet.
 * The translet name is resolved using the following rules:
 * 1. if the _transletName attribute is set and its value is not "GregorSamsa",
 *    then _transletName is returned.
 * 2. otherwise get the translet name from the base name of the system ID
 * 3. return "GregorSamsa" if the result from step 2 is null.
 *
 * @param source The input Source
 * @return The name of the translet class
 */
private String getTransletBaseName(Source source)
{
    String transletBaseName = null;
    if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
        return _transletName;
    else {
        String systemId = source.getSystemId();
        if (systemId != null) {
            String baseName = Util.baseName(systemId);
            if (baseName != null) {
                baseName = Util.noExtName(baseName);
                transletBaseName = Util.toJavaName(baseName);
            }
        }
    }

    return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
}
 
Example 2
Source File: MexEntityResolver.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
    Transformer transformer = XmlUtil.newTransformer();
    for (Source source : wsdls) {
        XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
        try {
            transformer.transform(source, xsbr);
        } catch (TransformerException e) {
            throw new WebServiceException(e);
        }
        String systemId = source.getSystemId();

        //TODO: can we do anything if the given mex Source has no systemId?
        if(systemId != null){
            SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
            this.wsdls.put(systemId, doc);
        }
    }
}
 
Example 3
Source File: SourceTreeManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Put the source tree root node in the document cache.
 * TODO: This function needs to be a LOT more sophisticated.
 *
 * @param n The node to cache.
 * @param source The Source object to cache.
 */
public void putDocumentInCache(int n, Source source)
{

  int cachedNode = getNode(source);

  if (DTM.NULL != cachedNode)
  {
    if (!(cachedNode == n))
      throw new RuntimeException(
        "Programmer's Error!  "
        + "putDocumentInCache found reparse of doc: "
        + source.getSystemId());
    return;
  }
  if (null != source.getSystemId())
  {
    m_sourceTree.addElement(new SourceTree(n, source.getSystemId()));
  }
}
 
Example 4
Source File: MexEntityResolver.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
    Transformer transformer = XmlUtil.newTransformer();
    for (Source source : wsdls) {
        XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
        try {
            transformer.transform(source, xsbr);
        } catch (TransformerException e) {
            throw new WebServiceException(e);
        }
        String systemId = source.getSystemId();

        //TODO: can we do anything if the given mex Source has no systemId?
        if(systemId != null){
            SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
            this.wsdls.put(systemId, doc);
        }
    }
}
 
Example 5
Source File: MexEntityResolver.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
    Transformer transformer = XmlUtil.newTransformer();
    for (Source source : wsdls) {
        XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
        try {
            transformer.transform(source, xsbr);
        } catch (TransformerException e) {
            throw new WebServiceException(e);
        }
        String systemId = source.getSystemId();

        //TODO: can we do anything if the given mex Source has no systemId?
        if(systemId != null){
            SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
            this.wsdls.put(systemId, doc);
        }
    }
}
 
Example 6
Source File: MexEntityResolver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
    Transformer transformer = XmlUtil.newTransformer();
    for (Source source : wsdls) {
        XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
        try {
            transformer.transform(source, xsbr);
        } catch (TransformerException e) {
            throw new WebServiceException(e);
        }
        String systemId = source.getSystemId();

        //TODO: can we do anything if the given mex Source has no systemId?
        if(systemId != null){
            SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
            this.wsdls.put(systemId, doc);
        }
    }
}
 
Example 7
Source File: ProcessorInclude.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Get the base URI of the included or imported stylesheet,
 * if the user provided a URIResolver, then get the Source
 * object for the stylsheet from it, and get the systemId 
 * from that Source object, otherwise try to recover by
 * using the SysteIDResolver to figure out the base URI.
 * @param handler The handler that processes the stylesheet as SAX events,
 * and maintains state
 * @param s The Source object from a URIResolver, for the included stylesheet module,
 * so this will be null if there is no URIResolver set.
 */
private String getBaseURIOfIncludedStylesheet(StylesheetHandler handler, Source s)
        throws TransformerException {
    

    
    String baseURI;
    String idFromUriResolverSource;
    if (s != null && (idFromUriResolverSource = s.getSystemId()) != null) {
        // We have a Source obtained from a users's URIResolver,
        // and the system ID is set on it, so return that as the base URI
        baseURI = idFromUriResolverSource;
    } else {
        // The user did not provide a URIResolver, or it did not 
        // return a Source for the included stylesheet module, or
        // the Source has no system ID set, so we fall back to using
        // the system ID Resolver to take the href and base
        // to generate the baseURI of the included stylesheet.
        baseURI = SystemIDResolver.getAbsoluteURI(getHref(), handler
                .getBaseIdentifier());
    }

    return baseURI;
}
 
Example 8
Source File: SourceTreeManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Put the source tree root node in the document cache.
 * TODO: This function needs to be a LOT more sophisticated.
 *
 * @param n The node to cache.
 * @param source The Source object to cache.
 */
public void putDocumentInCache(int n, Source source)
{

  int cachedNode = getNode(source);

  if (DTM.NULL != cachedNode)
  {
    if (!(cachedNode == n))
      throw new RuntimeException(
        "Programmer's Error!  "
        + "putDocumentInCache found reparse of doc: "
        + source.getSystemId());
    return;
  }
  if (null != source.getSystemId())
  {
    m_sourceTree.addElement(new SourceTree(n, source.getSystemId()));
  }
}
 
Example 9
Source File: TransformerFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the base class name of the translet.
 * The translet name is resolved using the following rules:
 * 1. if the _transletName attribute is set and its value is not "GregorSamsa",
 *    then _transletName is returned.
 * 2. otherwise get the translet name from the base name of the system ID
 * 3. return "GregorSamsa" if the result from step 2 is null.
 *
 * @param source The input Source
 * @return The name of the translet class
 */
private String getTransletBaseName(Source source)
{
    String transletBaseName = null;
    if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
        return _transletName;
    else {
        String systemId = source.getSystemId();
        if (systemId != null) {
            String baseName = Util.baseName(systemId);
            if (baseName != null) {
                baseName = Util.noExtName(baseName);
                transletBaseName = Util.toJavaName(baseName);
            }
        }
    }

    return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
}
 
Example 10
Source File: SourceTreeManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Put the source tree root node in the document cache.
 * TODO: This function needs to be a LOT more sophisticated.
 *
 * @param n The node to cache.
 * @param source The Source object to cache.
 */
public void putDocumentInCache(int n, Source source)
{

  int cachedNode = getNode(source);

  if (DTM.NULL != cachedNode)
  {
    if (!(cachedNode == n))
      throw new RuntimeException(
        "Programmer's Error!  "
        + "putDocumentInCache found reparse of doc: "
        + source.getSystemId());
    return;
  }
  if (null != source.getSystemId())
  {
    m_sourceTree.addElement(new SourceTree(n, source.getSystemId()));
  }
}
 
Example 11
Source File: TransformerFactoryImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Return the base class name of the translet.
 * The translet name is resolved using the following rules:
 * 1. if the _transletName attribute is set and its value is not "GregorSamsa",
 *    then _transletName is returned.
 * 2. otherwise get the translet name from the base name of the system ID
 * 3. return "GregorSamsa" if the result from step 2 is null.
 *
 * @param source The input Source
 * @return The name of the translet class
 */
private String getTransletBaseName(Source source)
{
    String transletBaseName = null;
    if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
        return _transletName;
    else {
        String systemId = source.getSystemId();
        if (systemId != null) {
            String baseName = Util.baseName(systemId);
            if (baseName != null) {
                baseName = Util.noExtName(baseName);
                transletBaseName = Util.toJavaName(baseName);
            }
        }
    }

    return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
}
 
Example 12
Source File: SourceTreeManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Put the source tree root node in the document cache.
 * TODO: This function needs to be a LOT more sophisticated.
 *
 * @param n The node to cache.
 * @param source The Source object to cache.
 */
public void putDocumentInCache(int n, Source source)
{

  int cachedNode = getNode(source);

  if (DTM.NULL != cachedNode)
  {
    if (!(cachedNode == n))
      throw new RuntimeException(
        "Programmer's Error!  "
        + "putDocumentInCache found reparse of doc: "
        + source.getSystemId());
    return;
  }
  if (null != source.getSystemId())
  {
    m_sourceTree.addElement(new SourceTree(n, source.getSystemId()));
  }
}
 
Example 13
Source File: TransformerFactoryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the base class name of the translet.
 * The translet name is resolved using the following rules:
 * 1. if the _transletName attribute is set and its value is not "GregorSamsa",
 *    then _transletName is returned.
 * 2. otherwise get the translet name from the base name of the system ID
 * 3. return "GregorSamsa" if the result from step 2 is null.
 *
 * @param source The input Source
 * @return The name of the translet class
 */
private String getTransletBaseName(Source source)
{
    String transletBaseName = null;
    if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
        return _transletName;
    else {
        String systemId = source.getSystemId();
        if (systemId != null) {
            String baseName = Util.baseName(systemId);
            if (baseName != null) {
                baseName = Util.noExtName(baseName);
                transletBaseName = Util.toJavaName(baseName);
            }
        }
    }

    return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
}
 
Example 14
Source File: XmlUtils.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void setSystemId(Source source, URL contextUrl, String input) {
	if (source.getSystemId() == null) {
		String systemId = XmlUtils.getSystemId(contextUrl, input);
		if (systemId != null) {
			source.setSystemId(systemId);
		}
	}
}
 
Example 15
Source File: W3CMultiSchemaFactory.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public void switchSource(Source source, State newState) {
    String url = source.getSystemId();
    if (url != null && sysIds.contains(url)) {
        return;
    }
    super.switchSource(source, newState);
}
 
Example 16
Source File: SourceTreeManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Given a Source object, find the node associated with it.
   *
   * @param source The Source object to act as the key.
   *
   * @return The node that is associated with the Source, or null if not found.
   */
  public int getNode(Source source)
  {

//    if (source instanceof DOMSource)
//      return ((DOMSource) source).getNode();

    // TODO: Not sure if the BaseID is really the same thing as the ID.
    String url = source.getSystemId();

    if (null == url)
      return DTM.NULL;

    int n = m_sourceTree.size();

    // System.out.println("getNode: "+n);
    for (int i = 0; i < n; i++)
    {
      SourceTree sTree = (SourceTree) m_sourceTree.elementAt(i);

      // System.out.println("getNode -         url: "+url);
      // System.out.println("getNode - sTree.m_url: "+sTree.m_url);
      if (url.equals(sTree.m_url))
        return sTree.m_root;
    }

    // System.out.println("getNode - returning: "+node);
    return DTM.NULL;
  }
 
Example 17
Source File: WSDLInlineSchemaValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getSystemId(WSDLModel model) {
    // # 170429
    File file = model.getModelSource().getLookup().lookup(File.class);
     
    if (file != null) {
        return file.toURI().toString();
    }
    Source source = model.getModelSource().getLookup().lookup(Source.class);

    if (source != null) {
        return source.getSystemId();
    }
    return null;
}
 
Example 18
Source File: SourceTreeManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Given a Source object, find the node associated with it.
   *
   * @param source The Source object to act as the key.
   *
   * @return The node that is associated with the Source, or null if not found.
   */
  public int getNode(Source source)
  {

//    if (source instanceof DOMSource)
//      return ((DOMSource) source).getNode();

    // TODO: Not sure if the BaseID is really the same thing as the ID.
    String url = source.getSystemId();

    if (null == url)
      return DTM.NULL;

    int n = m_sourceTree.size();

    // System.out.println("getNode: "+n);
    for (int i = 0; i < n; i++)
    {
      SourceTree sTree = (SourceTree) m_sourceTree.elementAt(i);

      // System.out.println("getNode -         url: "+url);
      // System.out.println("getNode - sTree.m_url: "+sTree.m_url);
      if (url.equals(sTree.m_url))
        return sTree.m_root;
    }

    // System.out.println("getNode - returning: "+node);
    return DTM.NULL;
  }
 
Example 19
Source File: SourceTreeManager.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
   * Given a Source object, find the node associated with it.
   *
   * @param source The Source object to act as the key.
   *
   * @return The node that is associated with the Source, or null if not found.
   */
  public int getNode(Source source)
  {

//    if (source instanceof DOMSource)
//      return ((DOMSource) source).getNode();

    // TODO: Not sure if the BaseID is really the same thing as the ID.
    String url = source.getSystemId();

    if (null == url)
      return DTM.NULL;

    int n = m_sourceTree.size();

    // System.out.println("getNode: "+n);
    for (int i = 0; i < n; i++)
    {
      SourceTree sTree = (SourceTree) m_sourceTree.elementAt(i);

      // System.out.println("getNode -         url: "+url);
      // System.out.println("getNode - sTree.m_url: "+sTree.m_url);
      if (url.equals(sTree.m_url))
        return sTree.m_root;
    }

    // System.out.println("getNode - returning: "+node);
    return DTM.NULL;
  }
 
Example 20
Source File: MCRURIResolver.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Source resolve(String href, String base) throws TransformerException {
    String help = href.substring(href.indexOf(":") + 1);
    String stylesheets = new StringTokenizer(help, ":").nextToken();
    String target = help.substring(help.indexOf(":") + 1);

    String subUri = target.substring(target.indexOf(":") + 1);
    if (subUri.length() == 0) {
        return new JDOMSource(new Element("null"));
    }

    Map<String, String> params;
    StringTokenizer tok = new StringTokenizer(stylesheets, "?");
    stylesheets = tok.nextToken();

    if (tok.hasMoreTokens()) {
        params = getParameterMap(tok.nextToken());
    } else {
        params = Collections.emptyMap();
    }
    Source resolved = MCRURIResolver.instance().resolve(target, base);

    try {
        if (resolved != null) {
            if (resolved.getSystemId() == null) {
                resolved.setSystemId(target);
            }
            MCRSourceContent content = new MCRSourceContent(resolved);
            MCRXSLTransformer transformer = getTransformer(stylesheets.split(","));
            MCRParameterCollector paramcollector = MCRParameterCollector.getInstanceFromUserSession();
            paramcollector.setParameters(params);
            MCRContent result = transformer.transform(content, paramcollector);
            return result.getSource();
        } else {
            LOGGER.debug("MCRXslStyleResolver returning empty xml");
            return new JDOMSource(new Element("null"));
        }
    } catch (IOException e) {
        Throwable cause = e.getCause();
        while (cause != null) {
            if (cause instanceof TransformerException) {
                throw (TransformerException) cause;
            }
            cause = cause.getCause();
        }
        throw new TransformerException(e);
    }
}