gcxml/src/gcxml/XMLQuery.java
// show keys that match specified pdf version
show keys that match specified pdf version
show keys that match specified pdf version
public void SinceVersion(String pdfVersion){
        for (File file : files) {
            if (file.isFile() && file.canRead() && file.exists()) {
                try{
                    String inputFile = inputFolder + file.getName();
                    Document doc = domBuilder.parse(inputFile);
                    doc.getDocumentElement().normalize();
                    System.out.println("Working on " + file.getName());
                    XPath xPath =  XPathFactory.newInstance().newXPath();
                    String expression = "/PDF/OBJECT";
                    NodeList object_nodes = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
                    for (int i = 0; i < object_nodes.getLength(); i++) {
                        int keyCount = 0;
                        Node nNode = object_nodes.item(i);
                        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                            Element eElement = (Element) nNode;
                            String object_name = eElement.getAttribute("id"); 
                            NodeList entry_nodes = eElement.getElementsByTagName("ENTRY"); 
                            System.out.println("Keys introduced in pdf version " + pdfVersion + " for object " + object_name + ":");
                            for(int j = 0; j < entry_nodes.getLength(); j++){
                                Node entry = entry_nodes.item(j);
                                Element entry_elem = (Element) entry;
                                String nodeName = entry_elem.getElementsByTagName("NAME").item(0).getTextContent();
                                String nodeSinceVersion = entry_elem.getElementsByTagName("INTRODUCED").item(0).getTextContent();
                                if(pdfVersion.equals(nodeSinceVersion)){
                                    System.out.println("\t/" + nodeName);
                                    keyCount++;
                                }
                            }
                        }
                        if(keyCount == 0) {
                            System.out.println("No keys were found in this object.");
                        }
                    }
                    System.out.println("======================================================================");
                } catch (SAXException ex) {
                    Logger.getLogger(XMLQuery.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(XMLQuery.class.getName()).log(Level.SEVERE, null, ex);
                } catch (XPathExpressionException ex) {
                    Logger.getLogger(XMLQuery.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
public void SinceVersion ( String pdfVersion ) { for ( File file : files ) { if ( file . isFile ( ) && file . canRead ( ) && file . exists ( ) ) { try { String inputFile = inputFolder + file . getName ( ) ; Document doc = domBuilder . parse ( inputFile ) ; doc . getDocumentElement ( ) . normalize ( ) ; System . out . println ( "Working on " + file . getName ( ) ) ; XPath xPath = XPathFactory . newInstance ( ) . newXPath ( ) ; String expression = "/PDF/OBJECT" ; NodeList object_nodes = ( NodeList ) xPath . compile ( expression ) . evaluate ( doc , XPathConstants . NODESET ) ; for ( int i = 0 ; i < object_nodes . getLength ( ) ; i ++ ) { int keyCount = 0 ; Node nNode = object_nodes . item ( i ) ; if ( nNode . getNodeType ( ) == Node . ELEMENT_NODE ) { Element eElement = ( Element ) nNode ; String object_name = eElement . getAttribute ( "id" ) ; NodeList entry_nodes = eElement . getElementsByTagName ( "ENTRY" ) ; System . out . println ( "Keys introduced in pdf version " + pdfVersion + " for object " + object_name + ":" ) ; for ( int j = 0 ; j < entry_nodes . getLength ( ) ; j ++ ) { Node entry = entry_nodes . item ( j ) ; Element entry_elem = ( Element ) entry ; String nodeName = entry_elem . getElementsByTagName ( "NAME" ) . item ( 0 ) . getTextContent ( ) ; String nodeSinceVersion = entry_elem . getElementsByTagName ( "INTRODUCED" ) . item ( 0 ) . getTextContent ( ) ; if ( pdfVersion . equals ( nodeSinceVersion ) ) { System . out . println ( "\t/" + nodeName ) ; keyCount ++ ; } } } if ( keyCount == 0 ) { System . out . println ( "No keys were found in this object." ) ; } } System . out . println ( "======================================================================" ) ; } catch ( SAXException ex ) { Logger . getLogger ( XMLQuery . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } catch ( IOException ex ) { Logger . getLogger ( XMLQuery . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } catch ( XPathExpressionException ex ) { Logger . getLogger ( XMLQuery . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } } } }
show keys that match specified pdf version
show keys that match specified pdf version
// loop through *.xml grammar files found in "/xml" directory // load all "object" nodes using xpath // name of the object // load all "entry" nodes