As the app we're developing is growing in size we're finding we have the same exernal entities declared in multiple XSLT files. We'd like to "DRY" these up by having them in a single place. However our attempts at this have been less than successful.
We then declare the <!doctype in a file which is included by every XSL template (includeme.xslt).
<!DOCTYPE xsl:stylesheet [ <!ENTITY % entities SYSTEM "entities.dtd">
%entities; ]>
We then started to remove the exisiting entity declarations from our XSLT files at which point we found that we couldn't save the documents with the entities removed (even though they are included by includeme.xslt) It throws horrible errors about the entities used in the document not being declared.
This is happening because the entities are resolved by the XML parser at an earlier state (before the XSLT file is "handed" to the XSLT processor), so I'm afraid you can't be any DRY'er than having the DOCTYPE present in all files that use those entities, which really isn't any less DRY (wet?) than having the normal stylesheet boilerplate stuff in all files anyway, right?
So the doctype include stuff just needs to be included in every page? I can live with that. Might be worth editing the clean xslt template to include it as standard.
Update actually you can't rename it as .xslt as Umbraco throws a wobbler when you try to save it. A request has been put in to allow us to edit it in the UI on code plex:
DRY'ing up External Entities in Umbraco
Hi all. Wondering if anyone can help?
As the app we're developing is growing in size we're finding we have the same exernal entities declared in multiple XSLT files. We'd like to "DRY" these up by having them in a single place. However our attempts at this have been less than successful.
We used the "trick" described here ( http://pimpmyxslt.com/articles/entity-tricks-part2/ ) but are having problems.
We have our entities.dtd file containing the entities saved on the filesystem.
We then declare the <!doctype in a file which is included by every XSL template (includeme.xslt).
We then started to remove the exisiting entity declarations from our XSLT files at which point we found that we couldn't save the documents with the entities removed (even though they are included by includeme.xslt) It throws horrible errors about the entities used in the document not being declared.
Has anyone found a nice DRY solution to this?
Hi Jim,
This is happening because the entities are resolved by the XML parser at an earlier state (before the XSLT file is "handed" to the XSLT processor), so I'm afraid you can't be any DRY'er than having the DOCTYPE present in all files that use those entities, which really isn't any less DRY (wet?) than having the normal stylesheet boilerplate stuff in all files anyway, right?
/Chriztian
So the doctype include stuff just needs to be included in every page? I can live with that. Might be worth editing the clean xslt template to include it as standard.
Thanks Chriztian. That explains a lot.
So you know you can give the entities file a .xslt file extension and then Umbraco will let you edit it in the UI :)
Update actually you can't rename it as .xslt as Umbraco throws a wobbler when you try to save it. A request has been put in to allow us to edit it in the UI on code plex:
http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=27116
Please feel free to up vote it if you want it adding.
For now stick with .dtd extension and you will have to edit it outside of Umbraco :(
is working on a reply...