Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jim McKerchar 3 posts 24 karma points
    May 17, 2010 @ 17:50
    Jim McKerchar
    1

    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.

    <!ENTITY nbsp "&#x00A0;">
    <!ENTITY pound "&#163;">
    <!ENTITY middot "&#183;">

    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.

    Has anyone found a nice DRY solution to this?

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 17, 2010 @ 20:29
    Chriztian Steinmeier
    1

    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

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 17, 2010 @ 21:42
    Peter Duncanson
    0

    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.

  • Jim McKerchar 3 posts 24 karma points
    May 18, 2010 @ 12:12
    Jim McKerchar
    0

    Thanks Chriztian. That explains a lot.

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 18, 2010 @ 13:10
    Peter Duncanson
    0

    So you know you can give the entities file a .xslt file extension and then Umbraco will let you edit it in the UI :)

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 19, 2010 @ 23:54
    Peter Duncanson
    0

    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 :(

Please Sign in or register to post replies

Write your reply to:

Draft