public Source resolve(String href, String base) throws TransformerException {
   if (href == null || href.trim().length() == 0) {
     throw new TransformerException("href is null");
   }
   try {
     String aname = defaultXslStylesheetBase + href;
     if (aname.indexOf("..") != -1) {
       aname = new File(aname).getCanonicalPath().toString();
     }
     if (m_bundleContect.getBundle().getEntry(aname) == null) {
       aname = defaultXslStylesheetBase2 + href;
     }
     if (m_bundleContect.getBundle().getEntry(aname) == null) {
       aname = defaultXslStylesheetBase3 + href;
     }
     SAXSource ss =
         new SAXSource(new InputSource(m_bundleContect.getBundle().getEntry(aname).openStream()));
     XMLReader reader = m_saxParserFactory.newSAXParser().getXMLReader();
     ReaderConfig rc = ((WstxSAXParser) reader).getStaxConfig();
     rc.setXMLResolver(new XslURIResolver(m_bundleContect, m_saxParserFactory));
     ss.setXMLReader(reader);
     return ss;
   } catch (Exception e) {
     throw new RuntimeException("XslURIResolver.resolve", e);
   }
 }
  public Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion)
      throws IOException, XMLStreamException {
    String normEnc = null;

    // First, let's get the buffers...
    int bufSize = cfg.getInputBufferLength();
    if (bufSize < MIN_BUF_SIZE) {
      bufSize = MIN_BUF_SIZE;
    }
    if (mByteBuffer == null) { // non-null if we were passed a buffer
      mByteBuffer = cfg.allocFullBBuffer(bufSize);
    }

    resolveStreamEncoding();

    if (hasXmlDecl()) {
      // note: readXmlDecl will set mXml11Handling too
      readXmlDecl(mainDoc, xmlVersion);
      if (mFoundEncoding != null) {
        normEnc = verifyXmlEncoding(mFoundEncoding);
      }
    } else {
      /* We'll actually then just inherit whatever main doc had...
       * (or in case there was no parent, just copy the 'unknown')
       */
      mXml11Handling = (XmlConsts.XML_V_11 == xmlVersion);
    }

    // Now, have we figured out the encoding?

    if (normEnc == null) { // not via xml declaration
      /* 21-Sep-2007, TSa: As with any non-UTF-8 encoding, declaration
       * isn't optional any more. Besides, we need that information
       * anyway to know which variant it is.
       */
      if (mEBCDIC) {
        if (mFoundEncoding == null || mFoundEncoding.length() == 0) {
          reportXmlProblem(
              "Missing encoding declaration: underlying encoding looks like an EBCDIC variant, but no xml encoding declaration found");
        }
        // Hmmh. What should be the canonical name? Let's just use found encoding?
        normEnc = mFoundEncoding;
      } else if (mBytesPerChar == 2) { // UTF-16, BE/LE
        normEnc = mBigEndian ? CharsetNames.CS_UTF16BE : CharsetNames.CS_UTF16LE;
      } else if (mBytesPerChar == 4) { // UCS-4... ?
        /* 22-Mar-2005, TSa: JDK apparently has no way of dealing
         *   with these encodings... not sure if and how it should
         *   be dealt with, really. Name could be UCS-4xx... or
         *   perhaps UTF-32xx
         */
        normEnc = mBigEndian ? CharsetNames.CS_UTF32BE : CharsetNames.CS_UTF32LE;
      } else {
        // Ok, default has to be UTF-8, as per XML specs
        normEnc = CharsetNames.CS_UTF8;
      }
    }

    mInputEncoding = normEnc;

    /* And then the reader. Let's figure out if we can use our own fast
     * implementations first:
     */
    BaseReader r;

    // Normalized, can thus use straight equality checks now
    if (normEnc == CharsetNames.CS_UTF8) {
      r = new UTF8Reader(cfg, mIn, mByteBuffer, mInputPtr, mInputEnd, mRecycleBuffer);
    } else if (normEnc == CharsetNames.CS_ISO_LATIN1) {
      r = new ISOLatinReader(cfg, mIn, mByteBuffer, mInputPtr, mInputEnd, mRecycleBuffer);
    } else if (normEnc == CharsetNames.CS_US_ASCII) {
      r = new AsciiReader(cfg, mIn, mByteBuffer, mInputPtr, mInputEnd, mRecycleBuffer);
    } else if (normEnc.startsWith(CharsetNames.CS_UTF32)) {
      // let's augment with actual endianness info
      if (normEnc == CharsetNames.CS_UTF32) {
        mInputEncoding = mBigEndian ? CharsetNames.CS_UTF32BE : CharsetNames.CS_UTF32LE;
      }
      r = new UTF32Reader(cfg, mIn, mByteBuffer, mInputPtr, mInputEnd, mRecycleBuffer, mBigEndian);
    } else {
      // Nah, JDK needs to try it
      // Ok; first, do we need to merge stuff back?
      InputStream in = mIn;
      if (mInputPtr < mInputEnd) {
        in = new MergedStream(cfg, in, mByteBuffer, mInputPtr, mInputEnd);
      }
      /* 20-Jan-2006, TSa: Ok; although it is possible to declare
       *   stream as 'UTF-16', JDK may need help in figuring out
       *   the right order, so let's be explicit:
       */
      if (normEnc == CharsetNames.CS_UTF16) {
        mInputEncoding = normEnc = mBigEndian ? CharsetNames.CS_UTF16BE : CharsetNames.CS_UTF16LE;
      }
      try {
        return new InputStreamReader(in, normEnc);
      } catch (UnsupportedEncodingException usex) {
        throw new WstxIOException("Unsupported encoding: " + usex.getMessage());
      }
    }

    if (mXml11Handling) {
      r.setXmlCompliancy(XmlConsts.XML_V_11);
    }

    return r;
  }