cancel
Showing results for 
Search instead for 
Did you mean: 

DTD validation in Alfresco

abi2004
Champ in-the-making
Champ in-the-making
Hi,

I want to validate xml content against custom DTD on ingestion.  I tried to store DTD's in a space inside company_home and tries to refer it through SAX Parser and it is throwing File Not found exception.  Any suggestion to handle this issue?
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
It should work.   But how are you reading the DTD?    FileNotFound sounds like you are trying to read a file directly rather than an input stream.   You should be able to use the content service to get an input stream for an InputStreamReader or similar class.

abi2004
Champ in-the-making
Champ in-the-making
Thanks mrogers for your response,

I am using InputStream only and still getting FileNotFound Exception, here is my code snippet

InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(inputString));
inputSource.setSystemId("/company_home/dtds");

mrogers
Star Contributor
Star Contributor
I don't see how that code would work.  

You need to find the node and then use the content service to get a content reader for that node 
Then you can create the InputSource with the input stream.

Or alternativly you may be able to specify the full URL /company_home/dtds rather than just a bit of the path.

abi2004
Champ in-the-making
Champ in-the-making
Thanks mrogers and appreciate your feedback.

I tried using InputStream from ContentReader and used it as part of InputSource.  Again same error message.  I am not sure how to get full URL of /company_home/dtds folder.  Here is the code I used and it throws File Not found exception.

ContentReader reader = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
InputStream inputStream = reader.getContentInputStream();
InputSource inputSource = new InputSource(inputStream);
inputSource.setSystemId("/company_home/dtds/");

and my XML file has
<!DOCTYPE product PUBLIC "-//Company//Product//EN" "../custom/dtd/product.dtd" >