dap4/d4lib/src/main/java/dap4/dap4lib/DMRPrinter.java
static public String
    fqnXMLEscape(String fqn)
    {
        // Split the fqn into pieces
        StringBuilder xml = new StringBuilder();
        String segment = null;
        List<String> segments = Escape.backslashsplit(fqn, '/');
        for(int i = 1; i < segments.size() - 1; i++) {  // skip leading /
            segment = segments.get(i);
            segment = Escape.backslashUnescape(segment); // get to raw name
            segment = Escape.entityEscape(segment, "\"");// '"' -> &quot;
            segment = Escape.backslashEscape(segment, "/."); // re-escape
            xml.append("/");
            xml.append(segment);
        }
        // Last segment might be structure path, so similar processing,
        // but worry about '.'
        segment = segments.get(segments.size() - 1);
        segments = Escape.backslashsplit(segment, '.');
        xml.append("/");
        for(int i = 0; i < segments.size(); i++) {
            segment = segments.get(i);
            segment = Escape.backslashUnescape(segment); // get to raw name
            segment = Escape.entityEscape(segment, "\"");// '"' -> &quot;
            segment = Escape.backslashEscape(segment, "/."); // re-escape
            if(i > 0) xml.append(".");
            xml.append(segment);
        }
        return xml.toString();
    }
static public String
    fqnXMLEscape(String fqn)
    {
        // Split the fqn into pieces
        StringBuilder xml = new StringBuilder();
        String segment = null;
        List<String> segments = Escape.backslashsplit(fqn, '/');
        for(int i = 1; i < segments.size() - 1; i++) {  // skip leading /
            segment = segments.get(i);
            segment = Escape.backslashUnescape(segment); // get to raw name
            segment = Escape.entityEscape(segment, "\"");// '"' -> &quot;
            segment = Escape.backslashEscape(segment, "/."); // re-escape
            xml.append("/");
            xml.append(segment);
        }
        // Last segment might be structure path, so similar processing,
        // but worry about '.'
        segment = segments.get(segments.size() - 1);
        segments = Escape.backslashsplit(segment, '.');
        xml.append("/");
        for(int i = 0; i < segments.size(); i++) {
            segment = segments.get(i);
            segment = Escape.backslashUnescape(segment); // get to raw name
            segment = Escape.entityEscape(segment, "\"");// '"' -> &quot;
            segment = Escape.backslashEscape(segment, "/."); // re-escape
            if(i > 0) xml.append(".");
            xml.append(segment);
        }
        return xml.toString();
    }
static public String fqnXMLEscape ( String fqn ) { // Split the fqn into pieces StringBuilder xml = new StringBuilder ( ) ; String segment = null ; List < String > segments = Escape . backslashsplit ( fqn , ' ' ) ; for ( int i = 1 ; i < segments . size ( ) - 1 ; i ++ ) { // skip leading / segment = segments . get ( i ) ; segment = Escape . backslashUnescape ( segment ) ; // get to raw name segment = Escape . entityEscape ( segment , "\"" ) ; // '"' -> &quot; segment = Escape . backslashEscape ( segment , "/." ) ; // re-escape xml . append ( "/" ) ; xml . append ( segment ) ; } // Last segment might be structure path, so similar processing, // but worry about '.' segment = segments . get ( segments . size ( ) - 1 ) ; segments = Escape . backslashsplit ( segment , ' ' ) ; xml . append ( "/" ) ; for ( int i = 0 ; i < segments . size ( ) ; i ++ ) { segment = segments . get ( i ) ; segment = Escape . backslashUnescape ( segment ) ; // get to raw name segment = Escape . entityEscape ( segment , "\"" ) ; // '"' -> &quot; segment = Escape . backslashEscape ( segment , "/." ) ; // re-escape if ( i > 0 ) xml . append ( "." ) ; xml . append ( segment ) ; } return xml . toString ( ) ; }
XML escape a dap fqn
and converting '"' to &quot;
Assumes backslash escapes are in effect for '/' and '.'

@param fqn the backslash escaped fqn
@return escaped string
XML escape a dap fqn and converting to &quot ; Assumes backslash escapes are in effect for / and .