Re: [xsl] How to modify a RDF document and preserve the <!DOCTYPE rdf:RDF[ and entity references?

Subject: Re: [xsl] How to modify a RDF document and preserve the <!DOCTYPE rdf:RDF[ and entity references?
From: Alex Muir <alex.g.muir@xxxxxxxxx>
Date: Sun, 6 Mar 2011 13:44:01 +0000
Hi,

Thanks for the replies. The enties are added I assume to reduce the
size of the document in this case.

I came across this post as well.
http://p2p.wrox.com/xslt/37057-preserving-entity-references.html

"The workaround people sometimes use is to edit the file before
transformation to replace all & characters by, say, 6, and then edit
the pilcrows back to ampersands after the transformation." MK

So probably then I'll just write a xsl that used unparsed-text() and
analyze-string to do that work around and go from there.

Thanks Much Guys

On Sun, Mar 6, 2011 at 1:25 PM, Andrew Welch <andrew.j.welch@xxxxxxxxx>
wrote:
> The short answer is you can't as the information gets lost when the
> xml is parsed.  There is an argument asking why you would want to -
> why do you want to recreate the entity refs?  XML is much nicer when a
> DTD isn't involved... :)
>
> Either way, if you really have to recreate the entity refs then (in
> Java) you can supply the XMLReader with your own LexicalHandler and
> DeclHandler to capture the parse events and turn them into markup and
> processing instructions to make the information available to your
> transform.  This is what Lexev does (http://andrewjwelch.com/lexev/)
> but it doesn't handle entity refs in attributes...  so its not much
> use here.
>
>
> On 6 March 2011 12:27, Alex Muir <alex.g.muir@xxxxxxxxx> wrote:
>> Hi,
>>
>> What do I need to add to an xslt 2.0 stylesheet that modifies an RDF
>> file which has a doctype declaration with entity references. I'm not
>> certain how to preserve the DOCTYPE here exactly as shown and also
>> preserve the entity references such &wiki; within the document.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE rdf:RDF[
>>    <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
>>    <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
>>    <!ENTITY owl 'http://www.w3.org/2002/07/owl#'>
>>    <!ENTITY swivt 'http://semantic-mediawiki.org/swivt/1.0#'>
>>    <!ENTITY wiki 'http://p13.itawiki.org/wiki/Special:URIResolver/'>
>>    <!ENTITY property
>> 'http://p13.itawiki.org/wiki/Special:URIResolver/Property-3A'>
>>    <!ENTITY wikiurl 'http://localhost/wiki/'>
>> ]>
>>
>> <rdf:RDF
>>    xmlns:rdf="&rdf;"
>>    xmlns:rdfs="&rdfs;"
>>    xmlns:owl ="&owl;"
>>    xmlns:swivt="&swivt;"
>>    xmlns:wiki="&wiki;"
>>    xmlns:property="&property;">
>>
>> Currently this is being replaced
>> <property:Office rdf:resource="&wiki;BX"/>
>>
>> as this in my xslt.
>>  <property:Office
>> rdf:resource="http://p13.itawiki.org/wiki/Special:URIResolver/BX"/>
>>
>> I've been reading some old posts on this but I haven't been able to
>> key in on the right solution via google.
>>
>> Regards
>> --
>> Alex
>> -----
>> Currently:
>> Freelance Software Engineer 6+ yrs exp
>>
>> Previously:
>> https://sites.google.com/a/utg.edu.gm/alex/
>>
>>
>> A Bafila, is two rivers flowing together as one:
>> http://www.facebook.com/pages/Bafila/125611807494851
>>
>>
>
>
>
> --
> Andrew Welch
> http://andrewjwelch.com
>



--
Alex
-----
Currently:
Freelance Software Engineer 6+ yrs exp

Previously:
https://sites.google.com/a/utg.edu.gm/alex/


A Bafila, is two rivers flowing together as one:
http://www.facebook.com/pages/Bafila/125611807494851

Current Thread