DTD + XML Catalog

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

DTD + XML Catalog

David Corbin
The Problem:

We have a DTD that is generated to match our schema.   We have many data set files in different packages and in different projects. 

To accommodate the different packages, or DOCTYPE usually looks like this:

<!DOCTYPE dataset SYSTEM "../../../../../zcorum-enterprise.dtd">

with a varying number "../"'s.  To accommodate the different projects, we're placing a copy of the DTD in each project that has a dataset.

What we want:
1 DTD file that is found from the classpath, with references that are non-relative.

What's been tried:
I've tried mucking around with overriding #resolveEntity in FlatXmlProducer and it hasn't been enough.  I specified a systemId of "foo.dtd", and despite the fact that my #resolveEntity returns an InputSource for it, I still get FileNotFoundException saying ".../src/main/java/com/package1/package2/package3/foo.dtd" is not found, when I'm loading the dataset in that package.  I'm not sure if it's some assumption made by dbunit, or if it's just that with the SAX parser encapsulated, i can't set the necessary entityResolver, though I lean toward the former.

This seems to me like it would be a very common problem/desire, but my Googling indicates otherwise.  Any suggestions on how to achieve our goal?

Thanks
David Corbin

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: DTD + XML Catalog

John Hurst-2
Hi,

I'm sorry I don't know the answer to your problem, but it does seem like a valid concern.

However, can I ask, out of curiosity, why you are using DTDs? In my own usage I use flat XML somewhat. But AFAIK the only use for DTD was for handling nulls. For myself, using a ReplacementDataSet for nulls was always sufficient, convenient and clear.

Regards

John Hurst



On Wed, Dec 4, 2013 at 1:57 AM, David Corbin <[hidden email]> wrote:
The Problem:

We have a DTD that is generated to match our schema.   We have many data set files in different packages and in different projects. 

To accommodate the different packages, or DOCTYPE usually looks like this:

<!DOCTYPE dataset SYSTEM "../../../../../zcorum-enterprise.dtd">

with a varying number "../"'s.  To accommodate the different projects, we're placing a copy of the DTD in each project that has a dataset.

What we want:
1 DTD file that is found from the classpath, with references that are non-relative.

What's been tried:
I've tried mucking around with overriding #resolveEntity in FlatXmlProducer and it hasn't been enough.  I specified a systemId of "foo.dtd", and despite the fact that my #resolveEntity returns an InputSource for it, I still get FileNotFoundException saying ".../src/main/java/com/package1/package2/package3/foo.dtd" is not found, when I'm loading the dataset in that package.  I'm not sure if it's some assumption made by dbunit, or if it's just that with the SAX parser encapsulated, i can't set the necessary entityResolver, though I lean toward the former.

This seems to me like it would be a very common problem/desire, but my Googling indicates otherwise.  Any suggestions on how to achieve our goal?

Thanks
David Corbin

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: DTD + XML Catalog

David Corbin
I was able to figure it out (right after my post, of course).  I've had to extend FlatXmlProducer, to make it work, and it seems like there should be a more direct way to make it work.  

Unfortunately, I had to upgrade dbunit from the ancient one we were using, and I've got all sorts of test failures from minor incompatabilities. :(

I'm not familiar with the alternative approach you describe. Can you elaborate?  One reason we use DTD's is so that when we're editing data set files, we have editorial-help.

David


On Wed, Dec 4, 2013 at 3:36 PM, John Hurst <[hidden email]> wrote:
Hi,

I'm sorry I don't know the answer to your problem, but it does seem like a valid concern.

However, can I ask, out of curiosity, why you are using DTDs? In my own usage I use flat XML somewhat. But AFAIK the only use for DTD was for handling nulls. For myself, using a ReplacementDataSet for nulls was always sufficient, convenient and clear.

Regards

John Hurst



On Wed, Dec 4, 2013 at 1:57 AM, David Corbin <[hidden email]> wrote:
The Problem:

We have a DTD that is generated to match our schema.   We have many data set files in different packages and in different projects. 

To accommodate the different packages, or DOCTYPE usually looks like this:

<!DOCTYPE dataset SYSTEM "../../../../../zcorum-enterprise.dtd">

with a varying number "../"'s.  To accommodate the different projects, we're placing a copy of the DTD in each project that has a dataset.

What we want:
1 DTD file that is found from the classpath, with references that are non-relative.

What's been tried:
I've tried mucking around with overriding #resolveEntity in FlatXmlProducer and it hasn't been enough.  I specified a systemId of "foo.dtd", and despite the fact that my #resolveEntity returns an InputSource for it, I still get FileNotFoundException saying ".../src/main/java/com/package1/package2/package3/foo.dtd" is not found, when I'm loading the dataset in that package.  I'm not sure if it's some assumption made by dbunit, or if it's just that with the SAX parser encapsulated, i can't set the necessary entityResolver, though I lean toward the former.

This seems to me like it would be a very common problem/desire, but my Googling indicates otherwise.  Any suggestions on how to achieve our goal?

Thanks
David Corbin

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: DTD + XML Catalog

John Hurst-2
Hello,

The tool help with DTDs is also a good reason. 

Glad you were able to solve your problem.

John Hurst


On Thu, Dec 5, 2013 at 11:08 PM, David Corbin <[hidden email]> wrote:
I was able to figure it out (right after my post, of course).  I've had to extend FlatXmlProducer, to make it work, and it seems like there should be a more direct way to make it work.  

Unfortunately, I had to upgrade dbunit from the ancient one we were using, and I've got all sorts of test failures from minor incompatabilities. :(

I'm not familiar with the alternative approach you describe. Can you elaborate?  One reason we use DTD's is so that when we're editing data set files, we have editorial-help.

David


On Wed, Dec 4, 2013 at 3:36 PM, John Hurst <[hidden email]> wrote:
Hi,

I'm sorry I don't know the answer to your problem, but it does seem like a valid concern.

However, can I ask, out of curiosity, why you are using DTDs? In my own usage I use flat XML somewhat. But AFAIK the only use for DTD was for handling nulls. For myself, using a ReplacementDataSet for nulls was always sufficient, convenient and clear.

Regards

John Hurst



On Wed, Dec 4, 2013 at 1:57 AM, David Corbin <[hidden email]> wrote:
The Problem:

We have a DTD that is generated to match our schema.   We have many data set files in different packages and in different projects. 

To accommodate the different packages, or DOCTYPE usually looks like this:

<!DOCTYPE dataset SYSTEM "../../../../../zcorum-enterprise.dtd">

with a varying number "../"'s.  To accommodate the different projects, we're placing a copy of the DTD in each project that has a dataset.

What we want:
1 DTD file that is found from the classpath, with references that are non-relative.

What's been tried:
I've tried mucking around with overriding #resolveEntity in FlatXmlProducer and it hasn't been enough.  I specified a systemId of "foo.dtd", and despite the fact that my #resolveEntity returns an InputSource for it, I still get FileNotFoundException saying ".../src/main/java/com/package1/package2/package3/foo.dtd" is not found, when I'm loading the dataset in that package.  I'm not sure if it's some assumption made by dbunit, or if it's just that with the SAX parser encapsulated, i can't set the necessary entityResolver, though I lean toward the former.

This seems to me like it would be a very common problem/desire, but my Googling indicates otherwise.  Any suggestions on how to achieve our goal?

Thanks
David Corbin

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: DTD + XML Catalog

Calen Legaspi
This post has NOT been accepted by the mailing list yet.
I had DbUnit ignore the DTD location by calling setDtdMetadata(false) on FlatXmlDataSetBuilder:

protected IDataSet getDataSet() throws Exception {
        FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
        builder.setDtdMetadata(false);
        return builder.build( getClass().getResourceAsStream("SectionDaoTest.xml") );
}