protected void outputPItoWriter(ProcessingInstruction currentPI,OutputStream writer,int position) throws IOException {
  if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
    writer.write('\n');
  }
  writer.write(BEGIN_PI.clone());
  final String target=currentPI.getTarget();
  int length=target.length();
  for (int i=0; i < length; i++) {
    char c=target.charAt(i);
    if (c == 0x0D) {
      writer.write(XD.clone());
    }
 else {
      if (c < 0x80) {
        writer.write(c);
      }
 else {
        UtfHelpper.writeCharToUtf8(c,writer);
      }
    }
  }
  final String data=currentPI.getData();
  length=data.length();
  if (length > 0) {
    writer.write(' ');
    for (int i=0; i < length; i++) {
      char c=data.charAt(i);
      if (c == 0x0D) {
        writer.write(XD.clone());
      }
 else {
        UtfHelpper.writeCharToUtf8(c,writer);
      }
    }
  }
  writer.write(END_PI.clone());
  if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
    writer.write('\n');
  }
}

protected void outputPItoWriter ( ProcessingInstruction currentPI , OutputStream writer , int position ) throws IOException { if ( position == NODE_AFTER_DOCUMENT_ELEMENT ) { writer . write ( '\n' ) ; } writer . write ( BEGIN_PI . clone ( ) ) ; final String target = currentPI . getTarget ( ) ; int length = target . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = target . charAt ( i ) ; if ( c == 0x0D ) { writer . write ( XD . clone ( ) ) ; } else { if ( c < 0x80 ) { writer . write ( c ) ; } else { UtfHelpper . writeCharToUtf8 ( c , writer ) ; } } } final String data = currentPI . getData ( ) ; length = data . length ( ) ; if ( length > 0 ) { writer . write ( ' ' ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = data . charAt ( i ) ; if ( c == 0x0D ) { writer . write ( XD . clone ( ) ) ; } else { UtfHelpper . writeCharToUtf8 ( c , writer ) ; } } } writer . write ( END_PI . clone ( ) ) ; if ( position == NODE_BEFORE_DOCUMENT_ELEMENT ) { writer . write ( '\n' ) ; } }
outputs a pi to the internal writer .
