0

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?

1 Answer 1

2

You need to declare the namespace in the global options of the select.

Log4j uses the namespace below.

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

You haven't given us your full config.xml but from a guess I think your XMLStarlet command should be something like the following.

xml sel -N log4j="http://jakarta.apache.org/log4j/" -t -m "Config/Application/Logger/log4j:configiguration/" -v "@rmiPort" -n config.xml

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.