Page 1 of 1

Trouble validating log4j config with DTD

Posted: Tue Oct 26, 2004 12:10 am
by dsmiley
I'm having trouble validating log4j files I use with the DTD. The log4j.dtd comes with the distribution in the source tree. I went into the default Oxygen catalog and I added an entry based off of the other entries I saw (catalogs are new to me).

Sample header of a log4j file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
My log4jcatalog file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system systemId="log4j.dtd" uri="log4j.dtd"/>
</catalog>
I basically just edited a copy of the SVG one to my liking. I put the log4j.dtd file in this same location and I edited the catalog.xml to refer to this file above.

So Oxygen doesn't seem to see this file at all. I try to validate a log4j config file and I get:

Code: Select all

	F FileNotFoundException-/Volumes/scratch/SmileyDev/jboss/server/default/conf/log4j.dtd (No such file or directory) 
Bummer. My platform is Mac OS X. Any ideas?

Posted: Thu Oct 28, 2004 9:39 am
by tavy
Dear David Smiley,

You don't need a catalog to validate your log4j files. Just make sure you have the log4j.dtd in the same folder as the log4j files or if the log4j.dtd
is in another folder specify the full path to the dtd in the header of your log4j files. In this case the header of the log4j file must look like this :

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "the full path to log4j.dtd">
In your example i think the path is : file:/Volumes/scratch/SmileyDev/jboss/server/default/conf/log4j.dtd

Best Regards,
Octavian

Posted: Thu Oct 28, 2004 7:46 pm
by dsmiley
I appreciate your help but...

1. I don't want to have to put log4j.dtd wherever I may be viewing a log4j configuration file.

2. I don't want to have to modify DOCTYPE declarations in log4j configuration files.

I think my needs are reasonable. The catalog appears to address my needs but I can't get it to work for me.

Posted: Thu Oct 28, 2004 8:19 pm
by sorin_ristache
The fact that the field containing the full name of the default catalog is not editable should provide a reasonable hint this is not the way to tell Oxygen about your catalog. You should only enable or disable its use and not modify its contents. Adding your catalog to the list of catalogs displayed below the default catalog field (use the New button in the same Preferences page) provides exactly what you need. Do not forget to restart Oxygen so that changes to the XML catalog settings take effect.

Regards,
Sorin

Posted: Thu Oct 28, 2004 8:51 pm
by dsmiley
OK. I removed my change the Oxygen's catalog and I added the catalog via the provided mechansim.

I get the same result, which is the file-not-found error as it looks for log4j.dtd within the same file as the log4j.xml I'm looking at.

I thought perhaps it might help if I used an absolute path in my catalog file for the URI attribute so I used:
file:///Volumes/scratch/SmileyDev/Tools/oxygen Folder/frameworks/log4j/dtd/log4j.dtd"
But that had no effect.

Posted: Thu Oct 28, 2004 10:53 pm
by george
Hi David,

The XML Catalog acts as an entity resolver. If you use a relative reference in your document that will be expanded by the parser before calling the entity resolver. Therefore if you have a catalog entry containing only the log4j.dtd that will not match. Another thing that you should take into account is that some characters need to be encoded, for instance space should be replaced with %20. We will make a working sample with log4j and let you know the steps to make that work.

Best Regards,
George

Posted: Fri Oct 29, 2004 2:12 pm
by tavy
Dear David Smiley,

To make this work follow the next steps:
  • 1. Create a catalog (log4jcatalog.xml) and specify the systemId as an absolute path, the catalog must look like this :

    Code: Select all

    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
    "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
    <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <system systemId="file:/log4j.dtd" uri="log4j.dtd"/>
    </catalog>
    2. Add the log4j.dtd in the same folder as log4jcatalog.xml or if the log4j.dtd is
    in another folder specify the path in the catalog : uri="the path to the dtd".
    3. Add the catalog to the oXygen catalogs list from Options->Preferences->XML Catalogs.
    4. Restart oXygen
    5. Create an xml file like this :

    Code: Select all

    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "file:/log4j.dtd">
    <log4j:configuration>
    </log4j:configuration>
    6. Try to validate your xml file.
Best Regards,
Octavian