namespace optimizations

git-svn-id: http://yolanda.mister-muffin.de/svn@337 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-30 09:57:24 +00:00
parent a4bf4da51c
commit 8dff628b5a
6 changed files with 59 additions and 128 deletions

View file

@ -41,11 +41,16 @@
<string id="video_audio_bitrate">64</string>
<string id="video_thumbnail_height">120</string>
<!-- settings for xml output -->
<!-- xml namespace URIs -->
<!--<string id="xml_namespace">http://feature.yolanda.namespace.tld</string>-->
<string id="xml_namespace_xsl">http://www.w3.org/1999/XSL/Transform</string>
<string id="xml_namespace_dc">http://purl.org/dc/elements/1.1/</string>
<string id="xml_namespace_dcterms">http://purl.org/dc/terms/</string>
<string id="xml_namespace_cc">http://web.resource.org/cc/</string>
<string id="xml_namespace_rdf">http://www.w3.org/1999/02/22-rdf-syntax-ns#</string>
<string id="xml_namespace_xforms">http://www.w3.org/2002/xforms</string>
<string id="xml_namespace_xsd">http://www.w3.org/2001/XMLSchema</string>
<string id="xml_namespace_xsi">http://www.w3.org/2001/XMLSchema-instance</string>
<string id="xml_namespace_xhtml">"http://www.w3.org/1999/xhtml"</string>
</strings>
</xsl:stylesheet>

View file

@ -34,10 +34,6 @@ sub get_page_array
#TODO: set namespace for each site on its own
$page->setAttribute( "username", $userinfo->{'username'} );
$page->setNamespace("http://www.w3.org/1999/xhtml", "xhtml", 0);
$page->setNamespace("http://web.resource.org/cc/", "cc", 0);
$page->setNamespace("http://purl.org/dc/elements/1.1/", "dc", 0);
$page->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
return $page;
}

View file

@ -11,6 +11,10 @@ my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
my $page = get_page_array(@userinfo);
$page->setNamespace( $config->{"xml_namespace_cc"}, "cc", 0);
$page->setNamespace( $config->{"xml_namespace_dc"}, "dc", 0);
$page->setNamespace( $config->{"xml_namespace_rdf"}, "rdf", 0);
#TODO: make the <frontpage> element unneccesary
$page->appendChild(XML::LibXML::Element->new( "frontpage" ));

View file

@ -11,6 +11,10 @@ my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
my $page = get_page_array(@userinfo);
$page->setNamespace( $config->{"xml_namespace_cc"}, "cc", 0);
$page->setNamespace( $config->{"xml_namespace_dc"}, "dc", 0);
$page->setNamespace( $config->{"xml_namespace_rdf"}, "rdf", 0);
#check if query is set
if($query->param('query'))
{

View file

@ -11,127 +11,45 @@ my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
my $page = get_page_array(@userinfo);
$page->setNamespace("http://www.w3.org/2002/xforms", "xforms", 0);
$page->setNamespace("http://www.w3.org/2001/XMLSchema", "xsd", 0);
$page->setNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi", 0);
$page->setNamespace( $config->{"xml_namespace_xforms"}, "xforms", 0);
$page->setNamespace( $config->{"xml_namespace_xsd"}, "xsd", 0);
$page->setNamespace( $config->{"xml_namespace_xsi"}, "xsi", 0);
$page->setNamespace( $config->{"xml_namespace_dcterms"}, "dcterms", 0 );
my $instance = XML::LibXML::Element->new( "instance" );
$instance->setNamespace("http://www.w3.org/2002/xforms", "xforms");
$instance->setNamespace( $config->{"xml_namespace_xforms"}, "xforms");
my $video = XML::LibXML::Element->new( "video" );
my $node = XML::LibXML::Element->new( "abstract" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:string" );
$video->appendChild($node);
sub getElementDC
{
my $node = XML::LibXML::Element->new( shift );
$node->setNamespace( $config->{"xml_namespace_dcterms"}, "dcterms" );
$node->setNamespace( $config->{"xml_namespace_xsi"}, "xsi", 0 );
$node->setAttributeNS( $config->{"xml_namespace_xsi"}, "type", shift );
return $node;
}
$node = XML::LibXML::Element->new( "alternative" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "contributor" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "created" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:date" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "creator" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "hasFormat" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "isFormatOf" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "isPartOf" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "language" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:language" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "license" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "references" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "replaces" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "rightsHolder" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "source" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "spatial" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "subject" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "temporal" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:date" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "title" );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
$video->appendChild($node);
$node = XML::LibXML::Element->new( "data" );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:base64Binary" );
$video->appendChild($node);
$video->appendChild( getElementDC( "abstract", "xsd:string") );
$video->appendChild( getElementDC( "alternative", "xsd:normalizedString") );
$video->appendChild( getElementDC( "contributor", "xsd:normalizedString") );
$video->appendChild( getElementDC( "created", "xsd:date") );
$video->appendChild( getElementDC( "creator", "xsd:normalizedString") );
$video->appendChild( getElementDC( "hasFormat", "xsd:normalizedString") );
$video->appendChild( getElementDC( "hasPart", "xsd:normalizedString") );
$video->appendChild( getElementDC( "isFormatOf", "xsd:normalizedString") );
$video->appendChild( getElementDC( "isPartOf", "xsd:normalizedString") );
$video->appendChild( getElementDC( "language", "xsd:language") );
$video->appendChild( getElementDC( "license", "xsd:normalizedString") );
$video->appendChild( getElementDC( "references", "xsd:normalizedString") );
$video->appendChild( getElementDC( "replaces", "xsd:normalizedString") );
$video->appendChild( getElementDC( "rightsHolder", "xsd:normalizedString") );
$video->appendChild( getElementDC( "source", "xsd:normalizedString") );
$video->appendChild( getElementDC( "spatial", "xsd:normalizedString") );
$video->appendChild( getElementDC( "subject", "xsd:normalizedString") );
$video->appendChild( getElementDC( "temporal", "xsd:date") );
$video->appendChild( getElementDC( "title", "xsd:normalizedString") );
$video->appendChild( getElementDC( "data", "xsd:base64Binary") );
$instance->appendChild($video);

View file

@ -11,6 +11,10 @@ my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
my $page = get_page_array(@userinfo);
$page->setNamespace( $config->{"xml_namespace_cc"}, "cc", 0);
$page->setNamespace( $config->{"xml_namespace_dc"}, "dc", 0);
$page->setNamespace( $config->{"xml_namespace_rdf"}, "rdf", 0);
#check if id or title is passed
if($query->url_param('id'))
{
@ -69,6 +73,14 @@ if($query->url_param('id'))
$page->setAttribute( "embed", "preview" );
}
#if there was a single result, display the video
my ($id, $title, $description, $publisher, $timestamp, $creator, $subject,
$source, $language, $coverage, $rights, $license,
$filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array();
#finish query
$sth->finish() or die $dbh->errstr;
#if user is logged in
if($userinfo->{'username'})
{
@ -180,14 +192,6 @@ if($query->url_param('id'))
}
}
}
#if there was a single result, display the video
my ($id, $title, $description, $publisher, $timestamp, $creator, $subject,
$source, $language, $coverage, $rights, $license,
$filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array();
#finish query
$sth->finish() or die $dbh->errstr;
#construct video xml
my $video = XML::LibXML::Element->new( "video" );