View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.xml.util;
8   
9   import org.mule.util.IOUtils;
10  
11  import java.io.IOException;
12  
13  import javax.xml.transform.URIResolver;
14  import javax.xml.transform.Source;
15  import javax.xml.transform.stream.StreamSource;
16  
17  /**
18   * Will look for the href file on the classpath
19   */
20  public class LocalURIResolver implements URIResolver
21  {
22      public Source resolve(String href, String base) throws javax.xml.transform.TransformerException
23      {
24          try
25          {
26              return new StreamSource(IOUtils.getResourceAsStream(href, getClass()));
27          }
28          catch (IOException e)
29          {
30              throw new javax.xml.transform.TransformerException(e);
31          }
32      }
33  }