private void transcodeItem(DicomInputStream in) throws SAXException,
IOException {
final DicomElement sq = in.sq();
final int itemLen = in.valueLength();
final VR sqvr = sq.vr();
final int index = sq.countItems();
if (file != null)
file = new File(file, Integer.toString(index+1));
final String fpath = fpath(sq.tag(), sqvr, itemLen);
startItemElement(in.tagPosition(), itemLen, fpath);
in.readValue(in);
if (sq.hasFragments() && index < sq.countItems()) {
byte[] data = sq.getFragment(index);
if (fpath != null) {
writeToFile(data);
} else {
final boolean bigEndian = in.getTransferSyntax().bigEndian();
sqvr.formatXMLValue(data, bigEndian, null, cbuf, ch);
}
sq.setFragment(index, EMPTY_BYTES);
}
endItemElement();
if (file != null)
file = file.getParentFile();
}