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_audio_bitrate">64</string>
<string id="video_thumbnail_height">120</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">http://feature.yolanda.namespace.tld</string>-->
<string id="xml_namespace_xsl">http://www.w3.org/1999/XSL/Transform</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_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_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_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> </strings>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -34,10 +34,6 @@ sub get_page_array
#TODO: set namespace for each site on its own #TODO: set namespace for each site on its own
$page->setAttribute( "username", $userinfo->{'username'} ); $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; return $page;
} }

View file

@ -11,6 +11,10 @@ my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
my $page = get_page_array(@userinfo); 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 #TODO: make the <frontpage> element unneccesary
$page->appendChild(XML::LibXML::Element->new( "frontpage" )); $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); 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 #check if query is set
if($query->param('query')) 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); my $page = get_page_array(@userinfo);
$page->setNamespace("http://www.w3.org/2002/xforms", "xforms", 0); $page->setNamespace( $config->{"xml_namespace_xforms"}, "xforms", 0);
$page->setNamespace("http://www.w3.org/2001/XMLSchema", "xsd", 0); $page->setNamespace( $config->{"xml_namespace_xsd"}, "xsd", 0);
$page->setNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi", 0); $page->setNamespace( $config->{"xml_namespace_xsi"}, "xsi", 0);
$page->setNamespace( $config->{"xml_namespace_dcterms"}, "dcterms", 0 );
my $instance = XML::LibXML::Element->new( "instance" ); 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 $video = XML::LibXML::Element->new( "video" );
my $node = XML::LibXML::Element->new( "abstract" ); sub getElementDC
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" ); {
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 ); my $node = XML::LibXML::Element->new( shift );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:string" ); $node->setNamespace( $config->{"xml_namespace_dcterms"}, "dcterms" );
$video->appendChild($node); $node->setNamespace( $config->{"xml_namespace_xsi"}, "xsi", 0 );
$node->setAttributeNS( $config->{"xml_namespace_xsi"}, "type", shift );
return $node;
}
$node = XML::LibXML::Element->new( "alternative" ); $video->appendChild( getElementDC( "abstract", "xsd:string") );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" ); $video->appendChild( getElementDC( "alternative", "xsd:normalizedString") );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 ); $video->appendChild( getElementDC( "contributor", "xsd:normalizedString") );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" ); $video->appendChild( getElementDC( "created", "xsd:date") );
$video->appendChild($node); $video->appendChild( getElementDC( "creator", "xsd:normalizedString") );
$video->appendChild( getElementDC( "hasFormat", "xsd:normalizedString") );
$node = XML::LibXML::Element->new( "contributor" ); $video->appendChild( getElementDC( "hasPart", "xsd:normalizedString") );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" ); $video->appendChild( getElementDC( "isFormatOf", "xsd:normalizedString") );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 ); $video->appendChild( getElementDC( "isPartOf", "xsd:normalizedString") );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" ); $video->appendChild( getElementDC( "language", "xsd:language") );
$video->appendChild($node); $video->appendChild( getElementDC( "license", "xsd:normalizedString") );
$video->appendChild( getElementDC( "references", "xsd:normalizedString") );
$node = XML::LibXML::Element->new( "created" ); $video->appendChild( getElementDC( "replaces", "xsd:normalizedString") );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" ); $video->appendChild( getElementDC( "rightsHolder", "xsd:normalizedString") );
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 ); $video->appendChild( getElementDC( "source", "xsd:normalizedString") );
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:date" ); $video->appendChild( getElementDC( "spatial", "xsd:normalizedString") );
$video->appendChild($node); $video->appendChild( getElementDC( "subject", "xsd:normalizedString") );
$video->appendChild( getElementDC( "temporal", "xsd:date") );
$node = XML::LibXML::Element->new( "creator" ); $video->appendChild( getElementDC( "title", "xsd:normalizedString") );
$node->setNamespace( "http://purl.org/dc/terms/", "dcterms" ); $video->appendChild( getElementDC( "data", "xsd:base64Binary") );
$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);
$instance->appendChild($video); $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); 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 #check if id or title is passed
if($query->url_param('id')) if($query->url_param('id'))
{ {
@ -69,6 +73,14 @@ if($query->url_param('id'))
$page->setAttribute( "embed", "preview" ); $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 user is logged in
if($userinfo->{'username'}) if($userinfo->{'username'})
{ {
@ -181,14 +193,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 #construct video xml
my $video = XML::LibXML::Element->new( "video" ); my $video = XML::LibXML::Element->new( "video" );
$video->setAttribute('thumbnail', $config->{"url_root"}."/video-stills/thumbnails/$id"); $video->setAttribute('thumbnail', $config->{"url_root"}."/video-stills/thumbnails/$id");