outputter.output(xform.transform(inDoc), System.out);
dimDoc = xform.transform(inDoc); outputter.output(dimDoc, System.out); dimList = dimDoc.getRootElement().getChildren(); }   Context context = new Context(); Iterator di = dimList.iterator(); while (di.hasNext()) {  Object o = di.next(); if (!(o instanceof Element)) continue;  Element elt = (Element)o; if (elt.getName().equals("field") && elt.getNamespace().equals(DIM_NS)) { String schema = elt.getAttributeValue("mdschema"); String element = elt.getAttributeValue("element"); String qualifier = elt.getAttributeValue("qualifier"); MetadataSchema ms = MetadataSchema.find(context, schema); if (ms == null ) { System.err.println("DIM Error, Cannot find metadata schema for: schema=\""+schema+ "\" (... element=\""+element+"\", qualifier=\""+qualifier+"\")"); } else { if (qualifier != null && qualifier.equals("")) { System.err.println("DIM Warning, qualifier is empty string: "+ " schema=\""+schema+"\", element=\""+element+"\", qualifier=\""+qualifier+"\""); qualifier = null; } MetadataField mf = MetadataField.findByElement(context, ms.getSchemaID(), element, qualifier); if (mf == null) System.err.println("DIM Error, Cannot find metadata field for: schema=\""+schema+ "\", element=\""+element+"\", qualifier=\""+qualifier+"\""); } } else {  throw new MetadataValidationException("Got unexpected element in DIM list: "+elt.toString()); }
    public static void main(String[] argv) throws Exception    {        if (argv.length < 2)        {            System.err.println("Usage:  java XSLTIngestionCrosswalk [-l] <crosswalk-name> <input-file>");            System.exit(1);        }        int i = 0;        boolean list = false;        // skip first arg if it's the list option        if (argv.length > 2 && argv[0].equals("-l"))        {            ++i;            list = true;        }        IngestionCrosswalk xwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(                IngestionCrosswalk.class, argv[i]);        XSLTransformer xform = ((XSLTIngestionCrosswalk)xwalk).getTransformer(DIRECTION);        if (xform == null)            throw new CrosswalkInternalException("Failed to initialize transformer, probably error loading stylesheet.");        SAXBuilder builder = new SAXBuilder();        Document inDoc = builder.build(new FileInputStream(argv[i+1]));        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());        if (list)        {            outputter.output(xform.transform(inDoc.getRootElement().getChildren()),                             System.out);        }        else        {            outputter.output(xform.transform(inDoc), System.out);        }    }