[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] How to modify a RDF document and preserve the
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 14:10:00 +0000

Yeah that's interesting. The entities are being used to represent a
URL. The URL's are repeated throughout the document thousands of times
so there is a savings in disk space.

<!ENTITY wikiurl 'http://localhost/wiki/'>

<rdfs:isDefinedBy
rdf:resource="&wikiurl;Special:ExportRDF/Property:OfficeCode"/>

 I suppose just the xml could be written differently?

<rdfs:isDefinedBy prefix="wikiurl"
rdf:resource="Special:ExportRDF/Property:OfficeCode"/>



On Sun, Mar 6, 2011 at 1:58 PM, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> The namespaces don't need to be declared on each element, but can be
> declared once on top of the document, this can be enforced in most cases.
> The reduction in size will then be marginal, if anything at all.
>
> If you consider the smaller size hoping for faster processing, think again,
> because all entity references will be expanded by the XML parser prior to
> being fed to the XSLT processor anyway. However, in-memory, the size of an
> element won't grow by it having a (larger) namespace due to the way it is
> stored internally. Remember, a namespace is _not_ an attribute.
>
> Kind regards,
> Abel Braaksma
>
>
> On 6-3-2011 14:44, Alex Muir wrote:
>>
>> 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
Keywords