I have an xml configuration file which works fine in Java, and I’m trying to parse out some info from it using XMLStarlet inside a script. The error I’m getting is:
xml sel -t -m "Config/Application" -v "@rmiPort" -n config.xml
namespace error : Namespace prefix log4j on configuration is not defined
<log4j:configuration>
^
config.xml has this declaration:
<?xml version="1.0"?>
<!DOCTYPE Config SYSTEM "../../../dtds/Config.dtd">
<Config>
...
<Logger>
<log4j:configuration>
...
config.dtd looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<!ENTITY % log4j:configuration SYSTEM "log4j.dtd">
%log4j:configuration;
...
<!ELEMENT Logger ((log4j:configuration)*)>
Any idea how I can fix the namespace, or quiet the error?
You need to declare the namespace in the global options of the select.
Log4j uses the namespace below.
You haven’t given us your full config.xml but from a guess I think your XMLStarlet command should be something like the following.
Hope that helps.