Skip to content

Commit

Permalink
Detect when in feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaben committed Nov 16, 2011
1 parent 4d4f832 commit 6923dd6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/OPDSRequirementsValidator.java
Expand Up @@ -63,6 +63,7 @@ public ErrorHandler getErrorHandler(){

}

/* TODO a file per class */
class OPDSRequirementFilter extends XMLFilterImpl {
Locator locator;
public void setDocumentLocator(Locator locator) {
Expand All @@ -75,12 +76,28 @@ protected Locator getLocator(){
return this.locator;
}


protected String getLocationString(){
if(locator!=null){
return ""+locator.getLineNumber()+":"+locator.getColumnNumber();
}
return "";
}

private boolean isFeed=false;
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException
{
if(!isFeed && name.equalsIgnoreCase("feed")){
isFeed=true;
}

super.startElement(uri,name,qName,atts);
}

protected boolean isFeed()
{
return isFeed;
}

}

Expand Down Expand Up @@ -475,7 +492,7 @@ class OPDSRequirementRootLink extends OPDSRequirementFilter {

public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException
{
if(name.equalsIgnoreCase("entry")){
if(isFeed() && name.equalsIgnoreCase("entry")){
in_entry=true;
}
if(!in_entry){
Expand Down Expand Up @@ -505,7 +522,7 @@ public void endElement (String uri, String name, String qName) throws SAXExcepti
}
public void endDocument () throws SAXException
{
if(root_count==0){
if(isFeed() && root_count==0){
warning(new SAXParseException("There SHOULD be a root catalog link (rel=\"start\")",getLocator()));
}
super.endDocument();
Expand Down

0 comments on commit 6923dd6

Please sign in to comment.