 |
Return to article.
Listing 4. WalkFilter kicks in the directory reading
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException
{
if(!namespaceURI.equals(this.namespaceURI))
super.startElement(namespaceURI,localName,qName,atts);
else
try
{
if(localName.equals("Directory"))
{
if(inDirectory)
messenger.error(new XMException(Resources.getString("nestedelement"),
new Object[] { qName }));
String dir = atts.getValue("dir");
if(dir == null || dir.trim().length() == 0)
messenger.error(new XMException(Resources.getString("dirrequired"),
new Object[] { qName }));
String stValue = atts.getValue("markSource");
boolean markSource = stValue != null && stValue.equalsIgnoreCase("true");
if(markSource && sourceFile == null)
throw new NotImplementedException("Caller has not set the sourceFile but the document wants it marked.");
File sourceDir = sourceFile != null ? sourceFile.getParentFile() : null,
dirFile = null;
if(sourceDir != null)
dirFile = new File(sourceDir,dir);
else
dirFile = new File(dir);
directoryReader.read(dirFile,markSource ? sourceFile : null);
inDirectory = true;
}
}
catch(XMException e)
{
throw new SAXException(e);
}
}
|
Return to article.
|  |
|