001 /* 002 * Copyright (c) 2006 Henri Sivonen 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a 005 * copy of this software and associated documentation files (the "Software"), 006 * to deal in the Software without restriction, including without limitation 007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 008 * and/or sell copies of the Software, and to permit persons to whom the 009 * Software is furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 017 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 019 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 020 * DEALINGS IN THE SOFTWARE. 021 */ 022 023 package fi.iki.hsivonen.verifierservlet; 024 025 import org.xml.sax.Attributes; 026 import org.xml.sax.ContentHandler; 027 import org.xml.sax.Locator; 028 import org.xml.sax.SAXException; 029 030 public class RootNamespaceSniffer implements ContentHandler { 031 032 private VerifierServletTransaction vst; 033 private ContentHandler ch; 034 private Locator locator; 035 036 public RootNamespaceSniffer(VerifierServletTransaction vst, ContentHandler ch) { 037 super(); 038 this.vst = vst; 039 this.ch = ch; 040 } 041 042 /** 043 * @see org.xml.sax.ContentHandler#characters(char[], int, int) 044 */ 045 public void characters(char[] arg0, int arg1, int arg2) throws SAXException { 046 ch.characters(arg0, arg1, arg2); 047 } 048 049 /** 050 * @see org.xml.sax.ContentHandler#endDocument() 051 */ 052 public void endDocument() throws SAXException { 053 ch.endDocument(); 054 } 055 056 /** 057 * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) 058 */ 059 public void endElement(String arg0, String arg1, String arg2) throws SAXException { 060 ch.endElement(arg0, arg1, arg2); 061 } 062 063 /** 064 * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String) 065 */ 066 public void endPrefixMapping(String arg0) throws SAXException { 067 ch.endPrefixMapping(arg0); 068 } 069 070 /** 071 * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) 072 */ 073 public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException { 074 ch.ignorableWhitespace(arg0, arg1, arg2); 075 } 076 077 /** 078 * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String) 079 */ 080 public void processingInstruction(String arg0, String arg1) throws SAXException { 081 ch.processingInstruction(arg0, arg1); 082 } 083 084 /** 085 * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator) 086 */ 087 public void setDocumentLocator(Locator arg0) { 088 this.locator = arg0; 089 ch.setDocumentLocator(arg0); 090 } 091 092 /** 093 * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) 094 */ 095 public void skippedEntity(String arg0) throws SAXException { 096 ch.skippedEntity(arg0); 097 } 098 099 /** 100 * @see org.xml.sax.ContentHandler#startDocument() 101 */ 102 public void startDocument() throws SAXException { 103 ch.startDocument(); 104 } 105 106 /** 107 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) 108 */ 109 public void startElement(String arg0, String arg1, String arg2, Attributes arg3) throws SAXException { 110 vst.rootNamespace(arg0, locator); 111 ch.startElement(arg0, arg1, arg2, arg3); 112 } 113 114 /** 115 * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) 116 */ 117 public void startPrefixMapping(String arg0, String arg1) throws SAXException { 118 ch.startPrefixMapping(arg0, arg1); 119 } 120 121 }