private void writeElement(DicomObject attrs, DicomElement a)
throws SAXException, IOException {
VR vr = a.vr();
final int tag = a.tag();
if (file != null)
file = new File(file, StringUtils.intToHex(tag));
String fpath = fpath(tag, vr, a.length());
startAttributeElement(tag, vr, a.length(), fpath, attrs);
if (a.hasItems()) {
for (int i = 0, n = a.countItems(); i < n; ++i) {
writeItem(a, i);
}
} else {
if (fpath != null) {
writeToFile(a.getBytes());
} else {
vr.formatXMLValue(a.getBytes(), a.bigEndian(),
attrs.getSpecificCharacterSet(), cbuf, ch);
}
}
endAttributeElement();
if (file != null)
file = file.getParentFile();
}