From: Carfield Yim on 30 Nov 2009 22:20 > I wish you lucks, then. > > Not sure it helps, but Verifier.isXMLCharacter(int) from JDOM will check > a character is a valid XML character (this same method is called to > raise the error you got.) > > Note it takes an int, not a char, as parameter. This is because it > handles non-BMP characters. You might want to do that too. > > -- > Mayeul Fixed, actually I can reuse API from JDOM to check if character is valid for XML document, or JDOM text, here is the code samples final String tempText; final StringBuilder content = new StringBuilder(); if (item instanceof FileItem) tempText = HeadItem.extendedDesc((FileItem) item); else tempText = item.getDesc(); /* from JDOM library... */ /* 159 */int i = 0; for (int len = tempText.length(); i < len; ++i) /* */{ /* 161 */final char ch = tempText.charAt(i); /* 164 */if (Verifier.isHighSurrogate(ch)) /* */{ /* 166 */++i; /* 167 */if (i < len) { /* 168 */char low = tempText.charAt(i); /* 169 */if (!(Verifier.isLowSurrogate(low))) { /* 170 */continue; /* */} /* */} /* */else { /* 177 */continue; /* */} /* */} /* 181 */if (!(Verifier.isXMLCharacter(ch))) /* */{ /* 185 */continue; /* */} /* */content.append(ch); /* */} /* */
|
Pages: 1 Prev: Join thread with SwingWorker objects Next: Can you write a foreach loop like this? |