Menu

charToByteConverterClass-Error

2004-08-24
2004-08-31
  • chandler.bing

    chandler.bing - 2004-08-24

    Hi,

    I just wanted to try your Saxon.NET-Beta1 and rewrote some code from the saxon samples in VB.Net (see below). When I try to run it, I'm getting "Warning: Could not get charToByteConverterClass!", but there is no sun.io to import?!

    Regards,
    Bjoern

    --- snip ---
    ' Create a transform factory instance.
    Dim tfactory As TransformerFactory = TransformerFactory.newInstance

    ' Create a transformer for the stylesheet.
    Dim trans As Transformer = tfactory.newTransformer(New StreamSource("C:\docbook\xsl\profiling\profile.xsl"))

    ' Transform the source XML to System.out.
    trans.transform(New StreamSource("02_docbook_mit_ausgewertetem_sql.xml"), New StreamResult(New java.io.File("saxon.net.xml")))
    --- snap ---

     
    • Pieter Siegers

      Pieter Siegers - 2004-08-31

      Hi Bjoern,

      You may want to check the following snippet that I use in a C# WinForm example project (which I will finish shortly):

      private void btnDoTransform_Click(object sender, System.EventArgs e)
      {
          /// prepare transform process
          InitTransform();

          /// do transform
          if (blnTransform == true)
          {
              try
              {
                  StreamSource inSource = new StreamSource(new java.io.FileInputStream(strAppPath + arrArgs[1]));
                  StreamSource xsltSource = new StreamSource(new java.io.FileInputStream(strAppPath + arrArgs[2]));

                  StreamResult outResult = new StreamResult();
                  java.io.FileOutputStream fos = new java.io.FileOutputStream(strAppPath + arrArgs[0]);
                  java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

                  if (outputToFile)
                  {
                      outResult.setOutputStream(fos);
                  }
                  else
                  {
                      outResult.setOutputStream(baos);
                  }

                  TransformerFactory transformF = TransformerFactory.newInstance();

                  Transformer transF = transformF.newTransformer(xsltSource);

                  transF.transform(inSource, outResult);

                  fos.close();

                  transF = null;
                  transformF = null;
                  outResult = null;
                  xsltSource = null;
                  inSource = null;
                  fos = null;

                  txtResult.Text = "Transformation of " + arrArgs[1] + " using " + arrArgs[2] + " is complete.";
                  if (outputToFile)
                      txtResult.Text += strCrLf + "The output has been written to " + arrArgs[0] + strCrLf;

                  string s = System.Text.UTF8Encoding.UTF8.GetString(ikvm.lang.ByteArrayHack.cast(baos.toByteArray()));

                  StringReader sr = new StringReader(s);

                  txtResult.Text += strCrLf + ConvOutputR(sr);
              }
              catch (Exception ex)
              {
                  txtResult.Text += ex.Message + strCrLf + ex.StackTrace;
              }
          }
      }

      Note that InitTransform() does some input argument preparation to set the variables to proper values.

      HTH!

      Cheers,
      Pieter

       

Log in to post a comment.