Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: FAQ candidate? parsing line-separated text files (was: Re: Off-topic: DOS script for XML directory listing)

From: Francis Norton <francis@----------->
To:
Date: 3/2/2000 3:40:00 PM
"Robert C. Lyons" wrote:

> I see one problem:
> The solution doesn't work if any of the file names
> in xmlDir.lst contains an ampersand
> (e.g., "Tom & Jerry.doc"), since an external parsed
> general entity (e.g., xmlDir.lst) can not contain
> an unescaped ampersand.
> 
Ouch! I hadn't thought of that.

> Perhaps there is a DOS command that is similar to
> the Unix sed command; your batch program could then
> replace each ampersand in the xmlDir.lst file with "&amp;".
> I'm not aware of such a DOS command.
> 
Nor am I. Unless there is a DOS edit.com guru out there...?

I was trying to do two things - (1) provide a utility, and (2) offer a
useful technique. I think the technique still stands, but with the
constraint that the input file can't contain ampersands.

I've written a little java program that can be called with jview (I hope
a reasonable assumption in most windows environments) and modified the
batch file. This should rescue the utility, if not its dignity.

Francis.<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xmlDir [
<!ENTITY xmlDirList
           SYSTEM "xmlDir.lst">    
  ]>

<xmlDir>&xmlDirList;</xmlDir>import java.io.*;

public class EscapeAmps
{
  static final int amp = '&';
  public static void main(String[] args)
  {
    int b;
    DataInputStream stdIn = new DataInputStream(System.in);
    try
    {
      while((-1)!=(b=stdIn.read()))
      {
        switch(b)
        {
          case amp:
          {
            System.out.print("&amp;");
            break;
          }
          default:
          {
            System.out.print((char)b);
            break;
          }
        }//switch (b)
      }//while(!eof())
    }
    catch(Exception e)
    {
      return;
    }
    return;
  }
}Attachment:
EscapeAmps.class

Description: application/java


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent