Pergunta

We have large project which uses immense amount of tagx of our creation, and we are about to re factor the UIs underlying code. This means that many tagx will be merged, thrown away and views (jspx-s) rewritten. To be able to delegate the re factoring into reasonable pieces without conflicting with each other we would like to "map" the tagx calls.

Is there an easy way, or a tool maybe, that goes through the jspx/tagx files and lists which tagx they have called (not just the library, but the specific tagx)?

So for example:

create.jspx calls in its body:

  • c:if
  • form:create
  • form:dependency
  • myowntaglib1:myowntag1
  • myowntaglibN:myowntagN
  • etc

and app lists this out.

Foi útil?

Solução

Simplest way to do that would be to write simple java program that recursively goes through directories searching for jspx files, and using XML Parser, ie. SAX parser listen to

XMLStreamConstants.START_ELEMENT

and then displaying

xmlReader.getName().getLocalPart();

Sample code:

    XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
            List<TercCode> tercCodeList = new ArrayList<TercCode>();

            try {
                XMLStreamReader xmlReader = xmlFactory.createXMLStreamReader(fname, stream);

                while (xmlReader.hasNext()) {
                    // returns the event type
                    int eventType = xmlReader.next();

                    // returns event type for reference
                    if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT){
System.out.println(xmlReader.getName().getLocalPart());
}
} catch (XMLStreamException e) {
        e.printStackTrace();
    }

stream should be FileInputStream for fname file.

Instead of displaying tag names, you can put them to HashMap and display them after all file is parsed, you'll not get duplicates then.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top