示例#1
0
 public Inclusion(InclusionIntent intent) {
   super(intent.getScroll() != null ? intent.getScroll() : new Scroll());
   this.intent = intent;
   boolean xhtml = intent.getFile().endsWith(".xhtml");
   this.useMagic = !xhtml;
   try {
     parser = xhtml ? Wandler.getXHTMLParser() : Wandler.getHTMLParser();
     parser.setContentHandler(this);
     parser.setEntityResolver(new VoidResolver());
   } catch (SAXException ex) {
     throw new RuntimeException("Inclusion failed", ex);
   }
 }
示例#2
0
 public void startTransformedElement(String name, Attributes attributes) {
   if (ignoreBounds()) return;
   try {
     Reader in = getResources().open(intent.getFile());
     parser.parse(new InputSource(useMagic ? new MagicReader(in) : in));
   } catch (IOException ex) {
     String message = "Error reading " + intent.getFile();
     Logger.getLogger(Inclusion.class.getName()).log(Level.SEVERE, message, ex);
   } catch (SAXException ex) {
     int lineNumber = locator != null ? locator.getLineNumber() : -1;
     String message =
         "Error parsing " + intent.getFile() + (lineNumber != -1 ? " at line " + lineNumber : "");
     Logger.getLogger(Inclusion.class.getName()).log(Level.SEVERE, message, ex);
   } finally {
     if (Wandler.dlogLevel >= Wandler.DLOG_LEVEL_1 && intent.getScroll() != null) {
       intent.getScroll().checkUsed(true);
     }
   }
 }
示例#3
0
 @Override
 public String toString() {
   return "Inclusion(useMagic: "
       + useMagic
       + ", file: "
       + intent.getFile()
       + ", intent: "
       + intent
       + ")";
 }