Maybe I wasn't clear enough.. I wanted a way to get the schema from the xml.
This way I can manually check if the schema follows a certain pattern
(for example, if it contains 1.5 at the end, I will know I have a 1.5
schema/namespace).
Here's my bean:
**
*public class MyTriggerBean {
private List<String> xmlnsList;
public MyTriggerBean() {
super();
xmlnsList = new ArrayList<String>();
}
public void addXmlns(String newXmlns){
xmlnsList.add(newXmlns);
}
}*
and this is the code I'm using to parse the xml:
*...
Digester digester = new Digester();
digester.addObjectCreate("triggers", MyTriggerBean.class);
digester.addSetProperties("triggers","xmlns","xmlns");
digester.addSetNext("triggers/xmlns", "addXmlns");
digester.setNamespaceAware(true);
Object o = digester.parse(xmlFile.getCanonicalPath());
...
*
I hoped that all my xmlns declarations in the xml will be added to
MyTriggerBean class, in the xmlnsList variable.
Can anybody suggest what I did wrong ?
Thank you.
On Fri, Apr 23, 2010 at 5:25 PM, Ionut Scutaru <[email protected]>wrote:
> Hi everybody,
>
> I'm pretty new with Apache Commons Digester, so please forgive me if what
> I am asking is very simple..
>
> I have an xml document as the following:
>
> <trigger:triggers
> xsi:schemaLocation="http://my.company/trigger/v1.2/ trigger_1.2.xsd"
> xmlns:trigger="http://my.company/trigger/v1.2/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <trigger:triggerA>
> ..
> </trigger:triggerA>
> </trigger:triggers>
>
> What I would like to do is to find the schema version used by the xml file
> using Digester. I mention that I can get
> XML files using various schema versions, from 1.0 to 1.5.
>
> Any suggestions, please ?
>
> Thank you,
> Ionut
>