On Mon, Dec 7, 2015 at 5:35 PM, Anthony Baker <[email protected]> wrote:

> 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)?
>

It *reduces* the noise level if the RAT exclusion list is as small as
possible - so where it makes no difference, then I would say yes add them.
But I wouldn't get hung up on every little test file that can easily be
justified under the "contains no creative content" category.

Niall



> 2) Is the code above correct?
>
> Thanks,
> Anthony
>
>

Reply via email to