1 23 package com.sun.enterprise.tools.verifier; 24 25 import java.io.ByteArrayInputStream ; 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 29 import javax.xml.parsers.SAXParserFactory ; 30 31 import org.xml.sax.InputSource ; 32 import org.xml.sax.XMLReader ; 33 34 import com.sun.enterprise.logging.LogDomains; 35 import tools.com.sun.enterprise.util.XMLValidationHandler; 36 37 public class NameToken { 38 39 final static String XMLtop = 40 "<!DOCTYPE NameToken [ <!ELEMENT NameToken EMPTY> <!ATTLIST NameToken value NMTOKEN #REQUIRED>]> <NameToken value=\""; 42 43 final static String XMLbottom = "\"/>"; 45 private static Logger logger = LogDomains.getLogger( 47 LogDomains.AVK_VERIFIER_LOGGER); 48 49 56 public static boolean isNMTOKEN(String value) { 57 61 String XMLdoc = XMLtop + value + XMLbottom; 62 logger.log(Level.FINE, 63 "com.sun.enterprise.tools.verifier.NameToken.print", new Object []{XMLdoc}); 65 66 try { 67 InputSource source = new InputSource ( 68 new ByteArrayInputStream (XMLdoc.getBytes())); 69 SAXParserFactory spf = SAXParserFactory.newInstance(); 70 spf.setValidating(true); 71 XMLReader p = spf.newSAXParser().getXMLReader(); 73 p.setErrorHandler(new XMLValidationHandler()); 75 p.parse(source); 76 return true; 77 78 } catch (Exception e) { 79 return false; 80 } 81 } 82 } 83 84 85 | Popular Tags |