dap4/d4lib/src/main/java/dap4/dap4lib/DMRPrinter.java
void
    printXMLAttributes(DapNode node, CEConstraint ce, int flags)
            throws IOException
    {
        if((flags & PERLINE) != 0)
            printer.indent(2);

        // Print name first, if non-null and !NONAME
        // Note that the short name needs to use
        // entity escaping (which is done by printXMLattribute),
        // but backslash escaping is not required.
        String name = node.getShortName();
        if(name != null && (flags & NONAME) == 0) {
            name = node.getShortName();
            printXMLAttribute("name", name, flags);
        }

        switch (node.getSort()) {
        case DATASET:
            DapDataset dataset = (DapDataset) node;
            printXMLAttribute("dapVersion", dataset.getDapVersion(), flags);
            printXMLAttribute("dmrVersion", dataset.getDMRVersion(), flags);
            // boilerplate
            printXMLAttribute("xmlns", "http://xml.opendap.org/ns/DAP/4.0#", flags);
            printXMLAttribute("xmlns:dap", "http://xml.opendap.org/ns/DAP/4.0#", flags);
            break;

        case DIMENSION:
            DapDimension orig = (DapDimension) node;
            if(orig.isShared()) {//not Anonymous
                // name will have already been printed
                // Now, we need to get the size as defined by the constraint
                DapDimension actual = this.ce.getRedefDim(orig);
                if(actual == null)
                    actual = orig;
                long size = actual.getSize();
                printXMLAttribute("size", Long.toString(size), flags);
            }
            break;

        case ENUMERATION:
            printXMLAttribute("basetype", ((DapEnumeration) node).getBaseType().getTypeName(), flags);
            break;

        case VARIABLE:
            DapVariable var = (DapVariable) node;
            DapType basetype = var.getBaseType();
            if(basetype.isEnumType()) {
                printXMLAttribute("enum", basetype.getTypeName(), flags);
            }
            break;

        case ATTRIBUTE:
            DapAttribute attr = (DapAttribute) node;
            basetype = attr.getBaseType();
            printXMLAttribute("type", basetype.getTypeName(), flags);
            if(attr.getBaseType().isEnumType()) {
                printXMLAttribute("enum", basetype.getTypeName(), flags);
            }
            break;

        default:
            break; // node either has no attributes or name only
        } //switch
        if(!this.testing)
            printReserved(node);
        if((flags & PERLINE) != 0) {
            printer.outdent(2);
        }
    }
void
    printXMLAttributes(DapNode node, CEConstraint ce, int flags)
            throws IOException
    {
        if((flags & PERLINE) != 0)
            printer.indent(2);

        // Print name first, if non-null and !NONAME
        // Note that the short name needs to use
        // entity escaping (which is done by printXMLattribute),
        // but backslash escaping is not required.
        String name = node.getShortName();
        if(name != null && (flags & NONAME) == 0) {
            name = node.getShortName();
            printXMLAttribute("name", name, flags);
        }

        switch (node.getSort()) {
        case DATASET:
            DapDataset dataset = (DapDataset) node;
            printXMLAttribute("dapVersion", dataset.getDapVersion(), flags);
            printXMLAttribute("dmrVersion", dataset.getDMRVersion(), flags);
            // boilerplate
            printXMLAttribute("xmlns", "http://xml.opendap.org/ns/DAP/4.0#", flags);
            printXMLAttribute("xmlns:dap", "http://xml.opendap.org/ns/DAP/4.0#", flags);
            break;

        case DIMENSION:
            DapDimension orig = (DapDimension) node;
            if(orig.isShared()) {//not Anonymous
                // name will have already been printed
                // Now, we need to get the size as defined by the constraint
                DapDimension actual = this.ce.getRedefDim(orig);
                if(actual == null)
                    actual = orig;
                long size = actual.getSize();
                printXMLAttribute("size", Long.toString(size), flags);
            }
            break;

        case ENUMERATION:
            printXMLAttribute("basetype", ((DapEnumeration) node).getBaseType().getTypeName(), flags);
            break;

        case VARIABLE:
            DapVariable var = (DapVariable) node;
            DapType basetype = var.getBaseType();
            if(basetype.isEnumType()) {
                printXMLAttribute("enum", basetype.getTypeName(), flags);
            }
            break;

        case ATTRIBUTE:
            DapAttribute attr = (DapAttribute) node;
            basetype = attr.getBaseType();
            printXMLAttribute("type", basetype.getTypeName(), flags);
            if(attr.getBaseType().isEnumType()) {
                printXMLAttribute("enum", basetype.getTypeName(), flags);
            }
            break;

        default:
            break; // node either has no attributes or name only
        } //switch
        if(!this.testing)
            printReserved(node);
        if((flags & PERLINE) != 0) {
            printer.outdent(2);
        }
    }
void printXMLAttributes ( DapNode node , CEConstraint ce , int flags ) throws IOException { if ( ( flags & PERLINE ) != 0 ) printer . indent ( 2 ) ; // Print name first, if non-null and !NONAME // Note that the short name needs to use // entity escaping (which is done by printXMLattribute), // but backslash escaping is not required. String name = node . getShortName ( ) ; if ( name != null && ( flags & NONAME ) == 0 ) { name = node . getShortName ( ) ; printXMLAttribute ( "name" , name , flags ) ; } switch ( node . getSort ( ) ) { case DATASET : DapDataset dataset = ( DapDataset ) node ; printXMLAttribute ( "dapVersion" , dataset . getDapVersion ( ) , flags ) ; printXMLAttribute ( "dmrVersion" , dataset . getDMRVersion ( ) , flags ) ; // boilerplate printXMLAttribute ( "xmlns" , "http://xml.opendap.org/ns/DAP/4.0#" , flags ) ; printXMLAttribute ( "xmlns:dap" , "http://xml.opendap.org/ns/DAP/4.0#" , flags ) ; break ; case DIMENSION : DapDimension orig = ( DapDimension ) node ; if ( orig . isShared ( ) ) { //not Anonymous // name will have already been printed // Now, we need to get the size as defined by the constraint DapDimension actual = this . ce . getRedefDim ( orig ) ; if ( actual == null ) actual = orig ; long size = actual . getSize ( ) ; printXMLAttribute ( "size" , Long . toString ( size ) , flags ) ; } break ; case ENUMERATION : printXMLAttribute ( "basetype" , ( ( DapEnumeration ) node ) . getBaseType ( ) . getTypeName ( ) , flags ) ; break ; case VARIABLE : DapVariable var = ( DapVariable ) node ; DapType basetype = var . getBaseType ( ) ; if ( basetype . isEnumType ( ) ) { printXMLAttribute ( "enum" , basetype . getTypeName ( ) , flags ) ; } break ; case ATTRIBUTE : DapAttribute attr = ( DapAttribute ) node ; basetype = attr . getBaseType ( ) ; printXMLAttribute ( "type" , basetype . getTypeName ( ) , flags ) ; if ( attr . getBaseType ( ) . isEnumType ( ) ) { printXMLAttribute ( "enum" , basetype . getTypeName ( ) , flags ) ; } break ; default : break ; // node either has no attributes or name only } //switch if ( ! this . testing ) printReserved ( node ) ; if ( ( flags & PERLINE ) != 0 ) { printer . outdent ( 2 ) ; } }
Print info from the node that needs to be in the form of xml attributes
Print info from the node that needs to be in the form of xml attributes