rajivbal_98
asked on
Problems with Oracle Parser
Hi
I am using Oracle Parser xmlparserv2.jar
I am generating xml files and reading files through Oracle Parser
Well Sometimes i get value <= or >=
for example <xml> <= </xml>
This Gives error while parsing in Oracle parser
Well wht i have done replaced < with > and > with < . But i have generic bean which does all this stuff. Its not possible for to change everywhere . So can someone give me a function where in it should replace < to < and > to > ..
So any other solution you have it , it would be appreciated .
Plz give the answer as soon as possible .
Thkx
Regards
Rajiv
I am using Oracle Parser xmlparserv2.jar
I am generating xml files and reading files through Oracle Parser
Well Sometimes i get value <= or >=
for example <xml> <= </xml>
This Gives error while parsing in Oracle parser
Well wht i have done replaced < with > and > with < . But i have generic bean which does all this stuff. Its not possible for to change everywhere . So can someone give me a function where in it should replace < to < and > to > ..
So any other solution you have it , it would be appreciated .
Plz give the answer as soon as possible .
Thkx
Regards
Rajiv
Why not just do this at source?
<xml><![CDATA[ <= ]]></xml>
That's another way of doing it at source ;-)
Heh, true ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want one of those - here's one:
public class HTMLEscape
{
public static String escape( String s )
{
int len = s.length();
StringBuffer sb = new StringBuffer(len*5/4);
for ( int i = 0; i < len; i++ )
{
char c = s.charAt( i );
String elem = htmlchars[c&0xff];
sb.append( elem == null ? ""+c : elem );
}
return sb.toString();
}
private static String htmlchars[] = new String[256];
static
{
String entry[] = {
"nbsp", "iexcl", "cent", "pound", "curren", "yen", "brvbar",
"sect", "uml", "copy", "ordf", "laquo", "not", "shy", "reg",
"macr", "deg", "plusmn", "sup2", "sup3", "acute", "micro",
"para", "middot", "cedil", "sup1", "ordm", "raquo", "frac14",
"frac12", "frac34", "iquest",
"Agrave", "Aacute", "Acirc", "Atilde", "Auml", "Aring", "AElig",
"CCedil", "Egrave", "Eacute", "Ecirc", "Euml", "Igrave", "Iacute",
"Icirc", "Iuml", "ETH", "Ntilde", "Ograve", "Oacute", "Ocirc",
"Otilde", "Ouml","times", "Oslash", "Ugrave", "Uacute", "Ucirc",
"Uuml", "Yacute", "THORN", "szlig",
"agrave", "aacute", "acirc", "atilde", "auml", "aring", "aelig",
"ccedil", "egrave", "eacute", "ecirc", "euml", "igrave", "iacute",
"icirc", "iuml", "eth", "ntilde", "ograve", "oacute", "ocirc",
"otilde", "ouml", "divid", "oslash", "ugrave", "uacute", "ucirc",
"uuml", "yacute", "thorn", "yuml"
};
htmlchars['&'] = "&";
htmlchars['<'] = "<";
htmlchars['>'] = ">";
for ( int c = '\u00A0', i=0 ; c <= '\u00FF'; c++, i++ )
htmlchars[c] = "&"+entry[i]+";";
for ( int c = '\u0083', i=131 ; c <= '\u009f'; c++, i++ )
htmlchars[c] = "&#"+i+";";
htmlchars['\u0088']=htmlch ars['\u008 D']=htmlch ars['\u008 E'] = null;
htmlchars['\u008F']=htmlch ars['\u009 0']=htmlch ars['\u009 8'] = null;
htmlchars['\u009D'] = null;
}
// For testing
public static void main( String args[] )
{
System.out.println(HTMLEsc ape.escape ("\""));
}
}
public class HTMLEscape
{
public static String escape( String s )
{
int len = s.length();
StringBuffer sb = new StringBuffer(len*5/4);
for ( int i = 0; i < len; i++ )
{
char c = s.charAt( i );
String elem = htmlchars[c&0xff];
sb.append( elem == null ? ""+c : elem );
}
return sb.toString();
}
private static String htmlchars[] = new String[256];
static
{
String entry[] = {
"nbsp", "iexcl", "cent", "pound", "curren", "yen", "brvbar",
"sect", "uml", "copy", "ordf", "laquo", "not", "shy", "reg",
"macr", "deg", "plusmn", "sup2", "sup3", "acute", "micro",
"para", "middot", "cedil", "sup1", "ordm", "raquo", "frac14",
"frac12", "frac34", "iquest",
"Agrave", "Aacute", "Acirc", "Atilde", "Auml", "Aring", "AElig",
"CCedil", "Egrave", "Eacute", "Ecirc", "Euml", "Igrave", "Iacute",
"Icirc", "Iuml", "ETH", "Ntilde", "Ograve", "Oacute", "Ocirc",
"Otilde", "Ouml","times", "Oslash", "Ugrave", "Uacute", "Ucirc",
"Uuml", "Yacute", "THORN", "szlig",
"agrave", "aacute", "acirc", "atilde", "auml", "aring", "aelig",
"ccedil", "egrave", "eacute", "ecirc", "euml", "igrave", "iacute",
"icirc", "iuml", "eth", "ntilde", "ograve", "oacute", "ocirc",
"otilde", "ouml", "divid", "oslash", "ugrave", "uacute", "ucirc",
"uuml", "yacute", "thorn", "yuml"
};
htmlchars['&'] = "&";
htmlchars['<'] = "<";
htmlchars['>'] = ">";
for ( int c = '\u00A0', i=0 ; c <= '\u00FF'; c++, i++ )
htmlchars[c] = "&"+entry[i]+";";
for ( int c = '\u0083', i=131 ; c <= '\u009f'; c++, i++ )
htmlchars[c] = "&#"+i+";";
htmlchars['\u0088']=htmlch
htmlchars['\u008F']=htmlch
htmlchars['\u009D'] = null;
}
// For testing
public static void main( String args[] )
{
System.out.println(HTMLEsc
}
}
I remember when it was just
© < > and ®
*sigh*
© < > and ®
*sigh*