/** * Reads and parses markup from a file. * * @return The markup * @throws IOException * @throws ResourceStreamNotFoundException */ public final Markup parse() throws IOException, ResourceStreamNotFoundException { // The root of all markup filters is the xml parser markupFilterChain = new RootMarkupFilter(xmlParser); // Convert the list of markup filters into a chain for (IMarkupFilter filter : getMarkupFilters()) { filter.setNextFilter(markupFilterChain); markupFilterChain = filter; } // Initialize the xml parser MarkupResourceStream markupResourceStream = markup.getMarkupResourceStream(); xmlParser.parse( markupResourceStream.getResource().getInputStream(), markupSettings.getDefaultMarkupEncoding()); // parse the xml markup and tokenize it into wicket relevant markup // elements parseMarkup(); // markupResourceStream.setEncoding(xmlParser.getEncoding()); markupResourceStream.setDoctype(xmlParser.getDoctype()); if (xmlParser.getEncoding() == null) { String a = "The markup file does not have a XML declaration prolog with 'encoding' attribute"; String b = ". E.g. <?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; if (markupSettings.getThrowExceptionOnMissingXmlDeclaration()) { throw new MarkupException(markupResourceStream.getResource(), a + b); } else { log.debug(a + ":" + markupResourceStream.getResource() + ". It is more save to use it" + b); } } return markup; }