I was adding licenses to XML files this weekend and noticed a problem. This code expects a certain structure to the xml doc that doesn’t allow for a comment:
/**
* Build <code>cache</code> element map for given <cod>doc</code>'s
* schemaLocation for {@link CacheXml#NAMESPACE}.
*
* @param doc
* {@link Document} to parse schema for.
* @return Element map
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
* @throws XPathExpressionException
* @since 8.1
*/
public static LinkedHashMap<String, CacheElement> buildElementMap(final
Document doc) throws IOException, XPathExpressionException, SAXException,
ParserConfigurationException {
final Map<String, List<String>> schemaLocationMap =
XmlUtils.buildSchemaLocationMap(
getAttribute(doc.getFirstChild(),
W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION,
W3C_XML_SCHEMA_INSTANCE_NS_URI));
final LinkedHashMap<String, CacheElement> elementMap = new
LinkedHashMap<String, CacheElement>();
buildElementMapCacheType(elementMap, resolveSchema(schemaLocationMap,
CacheXml.NAMESPACE));
// if we are ever concerned with the order of extensions or children
process them here.
return elementMap;
}
If you add a license header to CacheElementJUnitTest.xml and run
CacheElementJUnitTest you will get an NPE.
So two questions:
1) Do all of our test xml files need license headers (it does make the
exclusion list for RAT simple)?
2) Is the code above correct?
Thanks,
Anthony
signature.asc
Description: Message signed with OpenPGP using GPGMail
