I'm using Xerces-J-2.6.2 it barks at me with
org.xml.sax.SAX ParseException: InvalidRegex: Pattern value '[-+]?(\d+|\d+(\.\d+ )?%)(,\s*[-+]?(\d+|\d+(\.\d+ )?%))*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'
When i call this methd
through my test class providing
it works fine.
But when i ran it in Appserver WebSphere 6 it fails saying
org.xml.sax.SAX ParseException: InvalidRegex: Pattern value '[A-Za-z-.]*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'.
Please help.
Best Regards
Ashok
org.xml.sax.SAX ParseException: InvalidRegex: Pattern value '[-+]?(\d+|\d+(\.\d+ )?%)(,\s*[-+]?(\d+|\d+(\.\d+ )?%))*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'
When i call this methd
Code:
public void validateWithCache(String xml, EntityResolver resolver) {
// create the sax builder with the correct cache. This needs to be based on the
// XML passed in.
// find the first < in the xml
int index1 = xml.indexOf("<");
// find the first > in the xml
int index2 = xml.indexOf(">");
// get the string to use as our key
String key = xml.substring(index1, index2);
XMLGrammarPool pool = null;
if (!caches.containsKey(key)) {
synchronized (caches) {
if (!caches.containsKey(key)) {
pool = new XMLGrammarPoolImpl();
caches.put(key, pool);
}
}
}
if(pool == null)
{
pool = (XMLGrammarPool) caches.get(key);
}
XMLParserConfiguration config = new StandardParserConfiguration();
config.setProperty("http://apache.org/xml/properties/internal/grammar-pool", pool);
SAXParser parser = new SAXParser(config);
try {
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
} catch (SAXNotRecognizedException e) {
handleError(e, xml);
} catch (SAXNotSupportedException e) {
handleError(e, xml);
}
parser.setEntityResolver(resolver);
parser.setErrorHandler(this);
try {
StringReader characterStream = new StringReader(xml);
InputSource inputSource = new InputSource(characterStream);
parser.parse(inputSource);
} catch (SAXException e) {
handleError(e, xml);
} catch (IOException e) {
handleError(e, xml);
}
}
Code:
String salesXml="<Sale xmlns=\"" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"Sale.xsd\"><Branch>1370</Branch><TillNumber>1</TillNumber><TransactionNumber>1370001200606190000380</TransactionNumber><TimeStamp>2006-06-19T16:01:29</TimeStamp><Operator>9000037</Operator><AssistantID>601</AssistantID><ReferenceNumber>010038</ReferenceNumber><TradingDay>2006-05-13</TradingDay><Payments><SimplePayment><PaymentType>1</PaymentType><PaymentDetailType>1</PaymentDetailType><Amount>3.00</Amount></SimplePayment></Payments><Items><SimpleSale><ItemCode>0000033101</ItemCode><PlanningGroup>9033</PlanningGroup><SubPlanningGroup>9486</SubPlanningGroup><Quantity>1</Quantity><TotalSellingPrice>3.00</TotalSellingPrice><PriceOverridden>false</PriceOverridden><Scanned>false</Scanned><CommissionEarner>9000037</CommissionEarner><AssistantID>601</AssistantID></SimpleSale></Items></Sale>";
But when i ran it in Appserver WebSphere 6 it fails saying
org.xml.sax.SAX ParseException: InvalidRegex: Pattern value '[A-Za-z-.]*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'.
Please help.
Best Regards
Ashok