# HG changeset patch # User Bob Rosenberg # Date 1270545929 -3600 # Node ID 84b123918d3ff13cd95d0693f4878a32ff5567c1 # Parent 8d58b930d36ea5d3211079d8ad22b2777988c8db Added latest version of sysdeftools. See readme.txt for details on content. diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/LICENSE.xalan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/LICENSE.xalan Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,55 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xalan" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation and was + * originally based on software copyright (c) 1999, Lotus + * Development Corporation., http://www.lotus.com. For more + * information on the Apache Software Foundation, please see + * . + */ diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/docs/Changes for System Definition v2.0.0.doc Binary file sysdeftools/docs/Changes for System Definition v2.0.0.doc has changed diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/docs/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/docs/readme.txt Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,2 @@ +The specification for the 3.0.0 and System Definition syntaxes can be found at +http://developer.symbian.org/wiki/index.php/System_Definition diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/filter-module.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/filter-module.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + x + + + hide + + + + + + + + + + + + + + + + + + + + + + x + x + + + + hide + + + + + + + + + + + + + + + + x + + + hide + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/filtering.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/filtering.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,276 @@ + + + + + +only + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> +]]> + + \ No newline at end of file diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/group/sysdeftools.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/group/sysdeftools.mrp Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,7 @@ +component sysdeftools + +source \sf\os\buildtools\bldsystemtools\sysdeftools\ +notes_source \component_defs\release.src + + +ipr T diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/joinandparesysdef.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/joinandparesysdef.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,41 @@ + + + + + + + + + + +package + + + + + + + + + + + + + + + hide + + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/joinsysdef-module.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/joinsysdef-module.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,534 @@ + + + + + http://www.symbian.org/system-definition + + + + + ERROR: Cannot process this document + + + + + + + + + + + + + + + + + + ERROR: Linked ID "" () must match linking document "" () + + + + + + + + Cannot set "", already set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + + + + + + ERROR: Cannot create namespace prefix for downstream default namespace in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + ERROR: Could not find namespace for "" in + + + + + + + + + + + + + + + + + ERROR: Joining error in resolving namespace for "" in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + ../ + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/joinsysdef.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/joinsysdef.pl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,748 @@ +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +#!/usr/bin/perl + +use strict; + + +use FindBin; # for FindBin::Bin +use lib $FindBin::Bin; +use lib "$FindBin::Bin/lib"; + +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Spec; +use XML::DOM; + +my $output; +my $path; +my $config; +my @includes; +my %defineParams; +my %defines; +my $defaultns = 'http://www.symbian.org/system-definition'; # needed if no DTD + +my @newarg; +foreach my $a (@ARGV) + { #extract all -I parameters from the parameter list + if($a=~s/^-I//) + { + push(@includes,$a); + } + else + { + push(@newarg,$a); + } + } +@ARGV=@newarg; + +# need to add options for controlling which metas are filtered out and which are included inline +GetOptions + ( + 'path=s' => \$path, + 'output=s' => \$output, + 'config=s' => \$config + ); + +# -path specifies the full system-model path to the file which is being processed. +# This must be an absolute path if you're processing a root sysdef. +# If processing a pkgdef file, you can use "./package_definition.xml" to leave all links relative. Though I can't really see the use case for this. + +# -output specifies the file to save the output to. If not specified this will write to stdout + +# -config specifies the name of an .hrh file in which the configuration data is acquired from. If not set, no confguration will be done. + +# -I[path] specifies the include paths to use when resolving #includes in the .hrh file. Same syntax as cpp command uses. Any number of these can be provided. + + +# if config is not set, no confguration will be done. +# If it is set, all configuration metadata will be processed and stripped from the output, even if the confguration data is empty + + if($path eq '') {$path = '/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml'} + + +my $sysdef = &abspath(shift); # resolve the location of the root sysdef + + + +# rootmap is a mapping from the filesystem to the paths in the doc +my %rootmap = &rootMap($path,$sysdef); +my %nsmap; +my %urimap; + +if($config ne '') + { # run cpp to get all #defines + &getDefines($config); + } + +my $parser = new XML::DOM::Parser; +my $sysdefdoc = $parser->parsefile ($sysdef); + + +# find all the namespaces used in all trhe fragments and use that +# to set the namespaces ni the root element of the created doc +# should be able to optimise by only parsing each doc once and +# maybe skipping the contends of +my @nslist = &namespaces($sysdef,$sysdefdoc->getDocumentElement()); + + +while(@nslist) + { + my $uri = shift(@nslist); + my $prefix =shift(@nslist); + if($prefix eq 'id namespace'){$prefix=''} + if(defined $urimap{$uri}) {next} # already done this uri + $urimap{$uri} = $prefix; + if($nsmap{$prefix}) + { # need a new prefix for this, guess from the URI (for readability) + if($uri=~/http:\/\/(www\.)?([^.\/]+)\./) {$prefix = $2} + my $i=0; + while($nsmap{$prefix}) + { # still no prefix, just make up + $prefix="ns$i"; + $i++; + # next line not really necessary, but it's a good safety to stop infinite loops + $i eq 1000 && die "cannot create namespace prefix for $uri"; + } + } + $nsmap{$prefix}=$uri; + } + +my $docroot = $sysdefdoc->getDocumentElement; + +my $ns = $docroot->getAttribute('id-namespace'); +if(!$ns && $nsmap{''}) + { + $docroot->setAttribute('id-namespace',$nsmap{''}); + } +while(my($pre,$uri) = each(%nsmap)) + { + $pre ne '' || next ; + $docroot->setAttribute("xmlns:$pre",$uri); + } + +&walk($sysdef,$docroot); # process the XML + + +# print to file or stdout +if($output eq '') + { + print $sysdefdoc->toString; + } +else + { + $sysdefdoc->printToFile($output); + } + + +sub abspath + { # normalize the path into an absolute one + my ($name,$path) = fileparse($_[0]); + $path=~tr,\\,/,; + if( -e $path) + { + return abs_path($path)."/$name"; + } + my @dir = split('/',$_[0]); + my @new; + foreach my $d (@dir) + { + if($d eq '.') {next} + if($d eq '..') + { + pop(@new); + next; + } + push(@new,$d) + } + return join('/',@new); + } + +sub rootMap { + my @pathdirs = split(/\//,$_[0]); + my @rootdirs = split(/\//,$_[1]); + + while(lc($rootdirs[$#rootdirs]) eq lc($pathdirs[$#pathdirs]) ) + { + pop(@rootdirs); + pop(@pathdirs); + } + return (join('/',@rootdirs) => join('/',@pathdirs) ); + } + +sub rootMapMeta { + # find all the explict path mapping from the link-mapping metadata + my $node = shift; + foreach my $child (@{$node->getChildNodes}) + { + if ($child->getNodeType==1 && $child->getTagName eq 'map-prefix') + { + my $from = $child->getAttribute('link'); + my $to = $child->getAttribute('to'); # optional, but blank if not set + $rootmap{$from} = $to; + } + } + # once this is processed we have no more need for it. Remove from output + $node->getParentNode->removeChild($node); + } + + +sub walk + { # walk through the doc, resolving all links + my $file = shift; + my $node = shift; + my $type = $node->getNodeType; + if($type!=1) {return} + my $tag = $node->getTagName; + if($tag=~/^(layer|package|collection|component)$/ ) + { + if($file eq $sysdef) + { + &fixIDs($node); # normalise all IDs in the root doc. Child docs are handled elsewhere. + } + my $link= $node->getAttribute('href'); + if($link) + { + my $file = &resolvePath($file,$link); + if(-e $file) + { + &combineLink($node,&resolveURI($file,$link)); + } + else + { + print STDERR "Note: $file not found\n"; + } + return; + } + } + elsif($tag=~/^(SystemDefinition|systemModel)$/ ) + { + } + elsif($tag eq 'unit') + { + foreach my $atr ('bldFile','mrp','base','proFile') + { + my $link= $node->getAttribute($atr); + if($link && !($link=~/^\//)) + { + $link= &abspath(File::Basename::dirname($file)."/$link"); + foreach my $a (keys %rootmap) { + $link=~s,^$a,$rootmap{$a},ie; + } + # remove leading ./ which is used to indicate that paths should remain relative + $link=~s,^\./([^/]),$1,; + $node->setAttribute($atr,$link); + } + } + } + elsif($tag eq 'meta') + { + my $link= $node->getAttribute('href'); + $link=~s,^file://(/([a-z]:/))?,$2,; # convert file URI to absolute path + if ($link ne '' ) + { + if($link=~/^[\/]+:/) + { + print STDERR "Note: Remote URL $link not embedded\n"; + next; # do not alter children + } + if(! ($link=~/^\//)) + { + $link= &abspath(File::Basename::dirname($file)."/$link"); + } + if(! -e $link) + { + print STDERR "Warning: Local metadata file not found: $link\n"; + next; # do not alter children + } + # if we're here we can just embed the file + # no processing logic is done! It's just embedded blindly + my $metadoc = $parser->parsefile ($file); + my $item =&firstElement($metadoc->getDocumentElement); + if(!$item) + { + print STDERR "Warning: Could not process metadata file: $link\n"; + next; # do not alter children + } + $node->removeAttribute('href'); + foreach my $child (@{$item->getChildNodes}) + { + &blindCopyInto($node,$child); + next; + } + } + if($node->getAttribute('rel') eq 'link-mapping') + {# need to process this now + &rootMapMeta($node); + } + return; + } + else {return} + my $checkversion=0; + foreach my $item (@{$node->getChildNodes}) + { + #print $item->getNodeType,"\n"; + &walk($file,$item); + $checkversion = $checkversion || ($tag eq 'component' && $item->getNodeType==1 && $item->getAttribute('version') ne ''); + } + + if($checkversion && $config ne '') + { # need to check the conf metadata on the units in this component + &doCmpConfig($node); + } + foreach my $item (@{$node->getChildNodes}) + { + if ($item->getNodeType==1 && $item->getTagName eq 'meta') + { + &processMeta($item); + } + } + } + + +sub combineLink + { + # combine data from linked sysdef fragment w/ equivalent element in parent document + my $node = shift; + my $file = shift; + my $getfromfile = &localfile($file); + $getfromfile eq '' && return; # already raised warning, no need to repeat + my $doc = $parser->parsefile ($getfromfile); + my $item =&firstElement($doc->getDocumentElement); + $item || die "badly formatted $file"; + &fixIDs($item); + my %up = &atts($node); + my %down = &atts($item); + $up{'id'} eq $down{'id'} || die "$up{id} differs from $down{id}"; + $node->removeAttribute('href'); + foreach my $v (keys %up) {delete $down{$v}} + foreach my $v (keys %down) + { + $node->setAttribute($v,$down{$v}) + } + foreach my $child (@{$item->getChildNodes}) + { + ©Into($node,$child); + } + &walk($file,$node); + } + + +sub blindCopyInto + { + # make a deep copy the node (2nd arg) into the element (1st arg) + my $parent=shift; + my $item = shift; + my $doc = $parent->getOwnerDocument; + my $type = $item->getNodeType; + my $new; + if($type==1) + { + $new = $doc->createElement($item->getTagName); + my %down = &atts($item); + while(my($a,$b) = each(%down)) + { + $new->setAttribute($a,$b); + } + foreach my $child (@{$item->getChildNodes}) + { + &blindCopyInto($new,$child); + } + } + elsif($type==3) + { + $new = $doc->createTextNode ($item->getData); + } + elsif($type==8) + { + $new = $doc->createComment ($item->getData); + } + if($new) + { + $parent->appendChild($new); + } + } + +sub copyInto + { + # make a deep copy the node (2nd arg) into the element (1st arg) + my $parent=shift; + my $item = shift; + my $doc = $parent->getOwnerDocument; + my $type = $item->getNodeType; + my $new; + if($type==1) + { + &fixIDs($item); + $new = $doc->createElement($item->getTagName); + my %down = &atts($item); + foreach my $ordered ('id','name','bldFile','mrp','level','levels','introduced','deprecated','filter') + { + if($down{$ordered}) + { + $new->setAttribute($ordered,$down{$ordered}); + delete $down{$ordered} + } + } + while(my($a,$b) = each(%down)) + { + $new->setAttribute($a,$b); + } + foreach my $child (@{$item->getChildNodes}) + { + ©Into($new,$child); + } + } + elsif($type==3) + { + $new = $doc->createTextNode ($item->getData); + } + elsif($type==8) + { + $new = $doc->createComment ($item->getData); + } + if($new) + { + $parent->appendChild($new); + } + } + +sub getNs + { + # find the namespace URI that applies to the specified prefix. + my $node = shift; + my $pre = shift; + my $uri = $node->getAttribute("xmlns:$pre"); + if($uri) {return $uri} + my $parent = $node->getParentNode; + if($parent && $parent->getNodeType==1) + { + return getNs($parent,$pre); + } + } + + +sub fixIDs + { + # translate the ID to use the root doc's namespaces + my $node = shift; + foreach my $id ('id','before') + { + &fixID($node,$id); + } +} + +sub fixID + { + # translate the ID to use the root doc's namespaces + my $node = shift; + my $attr = shift || 'id'; + my $id = $node->getAttribute($attr); + if($id eq '') {return} + my $ns; + if($id=~s/^(.*)://) + { # it's got a ns, find out what it is + my $pre = $1; + $ns=&getNs($node,$pre); + } + else + { + $ns = $node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") || + $defaultns; + } + $ns = $urimap{$ns}; + $id = ($ns eq '') ? $id : "$ns:$id"; + return $node->setAttribute($attr,$id); +} + +sub firstElement { + # return the first element in this node + my $node = shift; + foreach my $item (@{$node->getChildNodes}) { + if($item->getNodeType==1) {return $item} + } +} + + +sub atts { + # return a hash of all attribtues defined for this element + my $node = shift; + my %at = $node->getAttributes; + my %list; + foreach my $a (keys %{$node->getAttributes}) + { + if($a ne '') + { + $list{$a} = $node->getAttribute ($a); + } + } + return %list; +} + + +sub ns + { + # return a hash of ns prefix and uri -- the xmlns: part is stripped off + my $node = shift; + my %list; + foreach my $a (keys %{$node->getAttributes}) + { + my $pre = $a; + if($pre=~s/^xmlns://) + { + $list{$pre} = $node->getAttribute ($a); + } + } + return %list; + } + + +sub resolvePath + { + # return full path to 2nd arg relative to first (path or absolute URI) + my $base = shift; + my $path = shift; + if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it. + if($path=~s,^file:///([a-zA-Z]:/),$1,) {return $path } # file URI with drive letter + if($path=~m,^file://,) {return $path } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it + if($path=~m,^[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- no idea how to handle, so just return + return &abspath(File::Basename::dirname($base)."/$path"); + } + + +sub resolveURI + { + # return full path to 2nd arg relative to first (path or absolute URI) + my $base = shift; + my $path = shift; + if($path=~m,[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- just return + if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it. + return &abspath(File::Basename::dirname($base)."/$path"); + } + +sub localfile + { + my $file = shift; + if($file=~s,file:///([a-zA-Z]:/),$1,) {return $file } # file URI with drive letter + if($file=~m,file://,) {return $file } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it + if($file=~m,^([a-z0-9][a-z0-9]+):,i) + { + print STDERR "ERROR: $1 scheme not supported\n"; + return; # return empty string if not supported. + } + return $file + } + +sub namespaces + { + # return a list of namespace URI / prefix pairs, in the order they're defined + # these need to be used to define namespaces in the root element + my $file = shift; + my $node = shift; + my $type = $node->getNodeType; + if($type!=1) {return} + my $tag = $node->getTagName; + my @res; + my %nslist = &ns($node); + while(my($pre,$uri)=each(%nslist)) + { # push all namespaces defined here onto the list + push(@res,$uri,$pre); + } + if($tag=~/^(layer|package|collection|component)$/ ) + { # these have the potential of linking, so check for that + my $link= $node->getAttribute('href'); + if($link) + { + $link=&resolvePath($file,$link); + if(-e $link) + { + my $doc = $parser->parsefile ($link); + my @docns = &namespaces($link,$doc->getDocumentElement); + undef $doc; + return (@res,@docns); + #ignore any children nodes if this is a link + } + print STDERR "Note: $link not found\n"; + } + } + elsif($tag eq 'SystemDefinition' ) + { + my $default = $node->getAttribute('id-namespace'); + if($default) + {# mangle with a space so it's clear it's not a qname + push(@res,$default,'id namespace'); + } + } + foreach my $item (@{$node->getChildNodes}) + { + push(@res,&namespaces($file,$item)); + } + return @res; + } + +sub processMeta + { # acts upon any known and strips it from the output if it's used + my $metanode = shift; + + my $rel = $metanode->getAttribute('rel') || 'Generic'; + if($rel eq 'config' && $config ne '') + { # only process if there is something to configure + &doconfig($metanode); + } + else + { + # do nothing. Not supported yet + } + } + +sub doCmpConfig + { # configure in or out the units in a component + my $cmp = shift; # the component node + my @unversioned; # list of all units with no version attribute (if more than one, they should all have filters defined) + my %versioned; # hash table of all units with a specified version, it's a fatal error to hav the same verison twice in one component + foreach my $item (@{$cmp->getChildNodes}) + { # populate %versioned and @unversioned to save processsing later + if($item->getNodeType==1 && $item->getTagName eq 'unit') + { + my $ver = $item->getAttribute('version'); + if($ver eq '') {push(@unversioned,$item)} + else + { + defined $versioned{$ver} && die "Cannot have more than one unit with version $ver in the same component ".$cmp->getAttribute('id'); + $versioned{$ver}=$item; + } + } + } + my @picks = &getMetaConfigPick($cmp); # the list, in order, of all elements that affect this component + foreach my $pick (@picks) + { + my $ver = $pick->getAttribute('version'); + if(!$versioned{$ver}) + { + print STDERR "ERROR: Reference to invalid unit version $ver in component ",$cmp->getAttribute('id'),". Ignoring.\n"; + return; + } + if(&definedMatches($pick)) + { # remove all other units; + delete $versioned{$ver}; # to avoid removing in loop + foreach my $unit (@unversioned, values(%versioned)) + { + $cmp->removeChild($unit); + print STDERR "Note: unit ",$unit->getAttribute('version')," in component " ,$cmp->getAttribute('id')," configured out\n"; + } + last; # done. No more processing after first match + } + else + { # remove this unit and continue + $cmp->removeChild($versioned{$ver}); + print STDERR "Note: unit $ver in component " ,$cmp->getAttribute('id')," configured out\n"; + delete $versioned{$ver}; # gone, don't process anymore; + } + } + if (scalar(@unversioned, values(%versioned)) > 1) + { + print STDERR "Warning: component ",$cmp->getAttribute('id')," has more than one unit after configuration\n"; + } + } + + +sub getMetaConfigPick + { # return an array of all elements that affect the specified element + my $node = shift; + my @pick; + while($node->getParentNode->getNodeType==1) + { + foreach my $item (@{$node->getChildNodes}) + { + my @picks; + if($item->getNodeType==1 && $item->getAttribute('rel') eq 'config') + { # it's conf metadata + foreach my $p (@{$item->getChildNodes}) + { + if($p->getNodeType==1 && $p->getTagName eq 'pick') {push(@picks,$p)} + } + } + @pick=(@picks,@pick); # prepend this to the start; + } + $node=$node->getParentNode; + } + return @pick; + } + +sub definedMatches + { # process all and the specified element and return true or false if the combination matches + my $node = shift; + my $match = 1; + foreach my $def (@{$node->getChildNodes}) + { + if($def->getNodeType == 1) + { + my $tag = $def->getTagName; + if($tag eq 'defined' or $tag eq 'not-defined') + { + my $var = $def->getAttribute('condition') || die "Must have condition set on all $tag elements"; + $defineParams{$var} && die "Cannot use a macro with parameters as a feature flag: $var(".$defineParams{$var}->[0].")"; + $match = $match && (($tag eq 'defined') ? defined($defines{$var}) : ! defined($defines{$var})); + } + } + } + return $match; + } + +sub doconfig + { # confgure in or out a system model item that owns the specified , remove the when done. + my $meta = shift; + my $keep = definedMatches($meta); + my $parent = $meta->getParentNode; + if(!$keep) + { + print STDERR "Note: ",$parent->getTagName," " ,$parent->getAttribute('id')," configured out\n"; + $parent->getParentNode->removeChild($parent); + return; # it's removed, so there's nothing else we can possibly do + } + + $parent->removeChild($meta); + } + +sub getDefines + { # populate the list of #defines from a specified .hrh file. + my $file = shift; + my $inc; + foreach my $i (@includes) + { + $inc.=" -I$i"; + } + open(CPP,"cpp -dD$inc \"$file\"|"); + while() + { + if(!/\S/){next} # skip blank lines + if(/^# [0-9]+ /) {next} # don't care about these + s/\s+$//; + if(s/^#define\s+(\S+)\((.*?)\)\s+//) + { #parametered define + push(@{$defineParams{$1}},@2,$_); + } + elsif(s/^#define\s+(\S+)//) + { # normal define + my $def = $1; + s/^\s+//; + $defines{$1}=$_; + } + else {die "cannot process $_";} + } + close CPP; + } diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/joinsysdef.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/joinsysdef.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,38 @@ + + + + + + +/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml + + + + + + + + + + + + + + + + + + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/mergesysdef-module.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/mergesysdef-module.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,504 @@ + + + +http://www.symbian.org/system-definition + + + ERROR: Syntax not supported + + + ERROR: Can only merge stand-alone system models + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Warning: need definition for namespace "" for + + + + + + + + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + + + + + + ERROR: Cannot create namespace prefix for downstream default namespace in + + + + + + + + + + + + + + + + + + + + + + + + ERROR: Syntax not supported + + + ERROR: Can only merge stand-alone system models + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Note: levels differ "" vs "" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Warning: "" moved in downstream model. Ignoring moved + + + + + + + + + + + + + + + Warning: All content in downstream "" is invalid. Ignoring + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Warning: "" moved in downstream model. Ignoring moved + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/mergesysdef.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/mergesysdef.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,100 @@ + + + + + mcl/System_Definition_Template.xml + + + + + + + + + Syntax not supported + + + + Upstream + + + + + + + + + + + Downstream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/readme.txt Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,21 @@ +Filtering tools: +filtering.xsl - Filter a sysdef in the 2.0 or 3.0 syntax + filter-module.xsl - XSLT module which contains the logic to process the filter attribute in the system definition + +Joining tools: +joinsysdef.pl - Create a stand-alone sysdef from a linked set of fragments. Supports confguring via an .hrh file. +joinsysdef.xsl - Create a stand-alone sysdef from a linked set of fragments +joinandparesysdef.xsl - Create a stand-alone sysdef from a linked set of fragments, paring down to just a set of items of the desired rank. + joinsysdef-module.xsl - XSLT module which contains the logic to join a system definition file + +Merging tools: +mergesysdef.xsl - Merge two 3.x syntax stand-alone system definitions + mergesysdef-module.xsl - XSLT module for merging only two sysdef files according to the 3.0.0 rules + +Other Tools: +sysdefdowngrade.xsl - Convert a 3.0.0 sysdef to 2.0.1 sytnax + +XSLT Processing: +xalan.jar +xercesImpl.jar +xml-apis.jar diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/rootsysdef.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/rootsysdef.pl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,744 @@ +use strict; + + +use FindBin; # for FindBin::Bin +use lib $FindBin::Bin; +use lib "$FindBin::Bin/lib"; + +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Spec; +use XML::DOM; + +my $output; +my $path; +my $defaultns = 'http://www.symbian.org/system-definition'; # needed if no DTD +my @searchpaths; +my @searchroots; +my %additional; +my %add; +my %newNs; +my $warning = "Error"; +my $placeholders=0; + +my @tdOrder =("hb","se", "lo","dc", "vc" , "pr", "dm", "de", "mm", "ma" , "ui", "rt", "to" ); + +# need to add options for controlling which metas are filtered out and which are included inline +GetOptions + ( + 'path=s' => \$path, + 'output=s' => \$output, + 'w=s' => \$warning, + 'root=s' => \@searchroots, + 'glob=s' => \@searchpaths, + 'placeholders=s' => \$placeholders + ); + + + if($path eq '') {$path = '/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml'} + +if(!($warning =~/^(Note|Warning|Error)$/)) {$warning="Error"} + +# path is the system model path of the processed sysdef file. This is only used when creating a stand-alone sysdef as the output +# output specifies the file this is saved in. If specified, all (relative) paths will be modified to be relative to it. If not, all paths will be absolute +# w is the warning level: Note, Warning or Error. +# root = -root g:\sf +# glob = -glob "\*\*\package_definition.xml" + +#rootsysdef.pl -root F:\dev\personal\sftest\sf\mcl -glob "\*\*\package_definition.xml" -output ..\..\..\deviceplatformrelease\nokia_system\system_definition.sf.xml ..\..\..\deviceplatformrelease\foundation_system\system_model\system_definition.xml + +my %replacefile; +my $dir; +foreach(@searchpaths) + { + my $ndir = shift(@searchroots); + if($ndir ne '') {$dir=$ndir} + foreach my $file (glob "$dir$_") + { + my $map =substr($file,length($dir)); + $map=~tr/\\/\//; + $additional{$map}=$file; + $replacefile{&abspath($file)}=$map; + $add{&abspath($file)}=1; + } + } + +my $sysdef = &abspath(shift); # resolve the location of the root sysdef + +# rootmap is a mapping from the filesystem to the paths in the doc +my %rootmap = &rootMap($path,$sysdef); +my %nsmap; +my %urimap; + + + +my $parser = new XML::DOM::Parser; +my $sysdefdoc = $parser->parsefile ($sysdef); + +my $mapmeta; +my $modpath; +if($output eq '') + { #figure out mapping path + my @fspath = split(/[\\\/]/,$sysdef); + my @smpath = split(/[\\\/]/,$path); + while(lc($smpath[$#smpath]) eq lc($fspath[$#fspath] )) { + pop(@smpath); + pop(@fspath); + } + my $mappath = join('/',@fspath); + my $topath = join('/',@smpath); + $mappath=~s,^/?,file:///,; + $mapmeta = $sysdefdoc->createElement('meta'); + $mapmeta->setAttribute('rel','link-mapping'); + my $node = $sysdefdoc->createElement('map-prefix'); + $node->setAttribute('link',$mappath); + $topath ne '' && $node->setAttribute('to',$topath); + $mapmeta->appendChild($node); + } +else + { + $modpath = &relativeTo(&abspath($output), $sysdef); + } + + +# find all the namespaces used in all trhe fragments and use that +# to set the namespaces ni the root element of the created doc +# should be able to optimise by only parsing each doc once and +# maybe skipping the contends of +my @nslist = &namespaces($sysdef,$sysdefdoc->getDocumentElement()); + +my %replacing; +my %newContainer; +my %foundDescendants; + +foreach(keys %add) + { + my $fragment = $parser->parsefile ($_); + my $fdoc = $fragment->getDocumentElement(); + my $topmost =&firstElement($fdoc); + my $type = $topmost->getTagName; + my $id = $topmost->getAttribute('id'); + my ($localid,$ns) = &idns($topmost,$id); + my @path = &guessIdInPath($localid,$_); + if($type eq 'layer') {@path=@path[0]} + elsif($type eq 'package') {@path=@path[0..1]} + elsif($type eq 'collection') {@path=@path[0..2]} + elsif($type eq 'component') {@path=@path[0..3]} + @path = reverse(@path); + $add{$_}=join('/',@path)." $localid $ns"; + $replacing{$type}->{"$localid $ns"} = $_; + # keys with a space are namespaced and fully identified, and contain the filename as the content. + # keys with no space have unknown namespace and contain a hash of the content + $newContainer{join('/',@path[0..$#path-1])}->{"$localid $ns"} = $_; + for(my $i=-1;$i<$#path-1;$i++) + { + $foundDescendants{$path[$i+1]}=1; + $newContainer{join('/',@path[0..$i])}->{$path[$i+1]}=1; + } + } + + +while(@nslist) + { + my $uri = shift(@nslist); + my $prefix =shift(@nslist); + if($prefix eq 'id namespace'){$prefix=''} + if(defined $urimap{$uri}) {next} # already done this uri + $urimap{$uri} = $prefix; + if($nsmap{$prefix}) + { # need a new prefix for this, guess from the URI (for readability) + if($uri=~/http:\/\/(www\.)?([^.\/]+)\./) {$prefix = $2} + my $i=0; + while($nsmap{$prefix}) + { # still no prefix, just make up + $prefix="ns$i"; + $i++; + # next line not really necessary, but it's a good safety to stop infinite loops + $i eq 1000 && die "ERROR: cannot create namespace prefix for $uri"; + } + } + $nsmap{$prefix}=$uri; + } + +my $docroot = $sysdefdoc->getDocumentElement; + +my $ns = $docroot->getAttribute('id-namespace'); +if(!$ns && $nsmap{''}) + { + $docroot->setAttribute('id-namespace',$nsmap{''}); + } +while(my($pre,$uri) = each(%nsmap)) + { + $pre ne '' || next ; + $docroot->setAttribute("xmlns:$pre",$uri); + } + +&walk($sysdef,$docroot); + +if($output eq '') + { + print $sysdefdoc->toString; + } +else + { + $sysdefdoc->printToFile($output); + } + + +sub abspath + { + # normalize the path into an absolute one + my ($name,$path) = fileparse($_[0]); + if($path eq '' && $name eq '') {return}; + $path=~tr,\\,/,; + if( -e $path) + { + return abs_path($path)."/$name"; + } + my @dir = split('/',$_[0]); + my @new; + foreach my $d (@dir) + { + if($d eq '.') {next} + if($d eq '..') + { + pop(@new); + next; + } + push(@new,$d) + } + return join('/',@new); + } + + + +sub normpath + { + # normalize the path + my @norm; + foreach my $dir(split(/[\\\/]/,shift)) { + if($dir eq '.') {next} + if($dir eq '..') + { + if($#norm == -1 || $norm[$#norm] eq '..') + { # keep as is + push(@norm,$dir); + } + elsif($#norm == 0 && $norm[0] eq '') + { # path begins with /, interpret /.. as just / -- ie toss out + next + } + else + { + pop(@norm); + } + } + else + { + push(@norm,$dir); + } + } + + return join('/',@norm) + } + + +sub rootMap { + my @pathdirs = split(/\//,$_[0]); + my @rootdirs = split(/\//,$_[1]); + + while(lc($rootdirs[$#rootdirs]) eq lc($pathdirs[$#pathdirs]) ) + { + pop(@rootdirs); + pop(@pathdirs); + } + return (join('/',@rootdirs) => join('/',@pathdirs) ); + } + +sub replacedBy + { # can only check once. Destroys data + my $node = shift; + my $fullid= join(' ',&idns($node)); + my $type = $node->getTagName; + my $repl = $replacing{$type}->{$fullid}; + delete $replacing{$type}->{$fullid}; + return $repl; + } + +sub walk + { + #' walk through the doc, resolving all links + my $file = shift; + my $node = shift; + my $type = $node->getNodeType; + if($type!=1) {return} + my $tag = $node->getTagName; + if($tag=~/^(layer|package|collection|component)$/ ) + { + if($file eq $sysdef) + { + &fixIDs($node); # normalise all IDs in the root doc. + } + my $override = &replacedBy($node); + my $link= $node->getAttribute('href'); + if($override eq '' ) + { + my ($id,$ns)=&idns($node); + if($foundDescendants{$id}) + { # keep this node, it'll be populated by what we found + if($link) + { + $node->removeAttribute('href'); + } + } + elsif($link || !$placeholders) + { # not going to be used, remove + $node->getParentNode->removeChild($node) ; # not present, remove + return; + } + } + else + { + my $href = $node->getAttribute('href'); + my $ppath = join('/',&parentPath($node->getParentNode)); + delete $newContainer{$ppath}->{join(' ',&idns($node))}; # remove this from list of things which need to be added + if(&resolvePath($file,$href) ne $override) + { # file has changed, update + print STDERR "$warning: Replacing $tag ",$node->getAttribute('id')," with $override\n"; + &setHref($node,$override); + return; + } + } + my @curpath = &parentPath($node); + my $curitem = $curpath[$#curpath]; + my $curp = join('/',@curpath[0..$#curpath-1]); + delete $newContainer{$curp}->{$curitem}; + + if($link) + { + foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children + &fixHref($node,$file); + return; + } + } + elsif($tag eq 'systemModel' && $mapmeta) + { # need absolute paths for all links + $node->insertBefore ($mapmeta,$node->getFirstChild); + } + elsif($tag=~/^(SystemDefinition|systemModel)$/ ) + { + } + elsif($tag eq 'unit') + { + foreach my $atr ('bldFile','mrp','base','proFile') + { + my $link= $node->getAttribute($atr); + if($link && !($link=~/^\//)) + { + if($mapmeta) + { # use absolute paths + $link= &abspath(File::Basename::dirname($file)."/$link"); + foreach my $a (keys %rootmap) + { + $link=~s,^$a,$rootmap{$a},ie; + } + } + else + { # modified relative path + $link = &normpath($modpath.$link); + } + $node->setAttribute($atr,$link); + } + } + } + elsif($tag eq 'meta') + { + &fixHref($node,$file); + &processMeta($node); + next; + } + else {return} + foreach my $item (@{$node->getChildNodes}) + { + #print $item->getNodeType,"\n"; + &walk($file,$item); + } + if($tag=~/^(systemModel|layer|package|collection|component)$/ ) + { # check for appending + my $ppath = join('/',&parentPath($node)); + if($newContainer{$ppath}) { + foreach my $item (sort keys %{$newContainer{$ppath}}) + { + &appendNewItem($node,$item,$newContainer{$ppath}->{$item}); + } + } + } + } + + +sub getNs + { + # find the ns URI that applies to the specified prefix. + my $node = shift; + my $pre = shift; + my $uri = $node->getAttribute("xmlns:$pre"); + if($uri) {return $uri} + my $parent = $node->getParentNode; + if($parent && $parent->getNodeType==1) + { + return getNs($parent,$pre); + } + } + + +sub fixIDs + { + # translate the ID to use the root doc's namespaces + my $node = shift; + foreach my $id ('id','before') + { + &fixID($node,$id); + } +} + +sub idns + { # return the namespace of an ID + my $node = shift; + my $id = shift; + if($id eq '' ) {$id = $node->getAttribute('id'); } + if($id=~s/^(.*)://) + { # it's got a ns, find out what it is + my $pre = $1; + return ($id,&getNs($node,$pre)); + } + return ($id,$node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") || $defaultns); + } + +sub fixID + { + # translate the ID to use the root doc's namespaces + my $node = shift; + my $attr = shift || 'id'; + my $id = $node->getAttribute($attr); + if($id eq '') {return} + my $ns; + if($id=~s/^(.*)://) + { # it's got a ns, find out what it is + my $pre = $1; + $ns=&getNs($node,$pre); + } + else + { + $ns = $node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") || + $defaultns; + } + $ns = $urimap{$ns}; + $id = ($ns eq '') ? $id : "$ns:$id"; + return $node->setAttribute($attr,$id); +} + +sub firstElement { + # return the first element in this node + my $node = shift; + foreach my $item (@{$node->getChildNodes}) { + if($item->getNodeType==1) {return $item} + } +} + + +sub atts { + # return a hash of all attribtues defined for this element + my $node = shift; + my %at = $node->getAttributes; + my %list; + foreach my $a (keys %{$node->getAttributes}) + { + if($a ne '') + { + $list{$a} = $node->getAttribute ($a); + } + } + return %list; +} + + +sub ns + { + # return a hash of ns prefix and uri -- the xmlns: part is stripped off + my $node = shift; + my %list; + foreach my $a (keys %{$node->getAttributes}) + { + my $pre = $a; + if($pre=~s/^xmlns://) + { + $list{$pre} = $node->getAttribute ($a); + } + } + return %list; + } + + + +sub namespaces + { + # return a list of namespace URI / prefix pairs, in the order they're defined + # these need to be used to define namespaces in the root element + my $file = shift; + my $node = shift; + my $type = $node->getNodeType; + if($type!=1) {return} + my $tag = $node->getTagName; + my @res; + my %nslist = &ns($node); + while(my($pre,$uri)=each(%nslist)) + { # push all namespaces defined here onto the list + push(@res,$uri,$pre); + } + if($tag=~/^(layer|package|collection|component)$/ ) + { # these have the potential of linking, so check for that + } + elsif($tag eq 'SystemDefinition' ) + { + my $default = $node->getAttribute('id-namespace'); + if($default) + {# mangle with a space so it's clear it's not a qname + push(@res,$default,'id namespace'); + } + } + foreach my $item (@{$node->getChildNodes}) + { + push(@res,&namespaces($file,$item)); + } + return @res; + } + +sub processMeta + { + my $metanode = shift; + # do nothing. Not supported yet + } + +sub guessIdInPath + { + my $id = shift; + my @path = reverse(split(/\//,shift)); + while(@path) + { + my $dir = shift(@path); + if($dir eq $id) + { + return ($id,@path); + } + } + } + + +sub parentPath + { + my $node=shift; + my @path; + while($node) + { + if(!$node) {return @path} + my $id=$node->getAttribute('id'); + if($id eq '') {return @path} + $id=~s/^.*://; + @path = ($id,@path); + $node = $node->getParentNode(); + } + return @path; + } + +sub childTag + { + my $tag = shift; + if($tag eq 'systemModel') {return 'layer'} + if($tag eq 'layer') {return 'package'} + if($tag eq 'package') {return 'collection'} + if($tag eq 'collection') {return 'component'} + die "ERROR: no child for $tag"; + } + +sub appendNewItem + { + my $node = shift; + my $doc = $node->getOwnerDocument; + my $id = shift; + my $fullid=$id; + my $contents = shift; + my $tag = &childTag($node->getTagName()); + my $new = $doc->createElement($tag); + if($id=~/^(.*) (.*)/) + { + $id=$1; + $ns = getNamespacePrefix($node,$2); + if($ns ne '') {$id="$ns:$id"} + } + else + { + $contents = ''; + } + $new->setAttribute('id',$id); # default namespace + $node->appendChild($new); + my $ppath = join('/',&parentPath($new)); + if($contents eq '') + { # look for additions + print STDERR "$warning: Adding new $tag: $id\n"; + if($newContainer{$ppath}) { + foreach my $item (sort keys %{$newContainer{$ppath}}) + { + &appendNewItem($new,$item,$newContainer{$ppath}->{$item}); + } + } + } + else + { # this one item is defined in the specified file + if($tag eq 'package') + { #include some package data in root + my $fragment = $parser->parsefile ($contents); + my $fdoc = $fragment->getDocumentElement(); + my $topmost =&firstElement($fdoc); + my %at = &atts($topmost); + foreach my $arg ('tech-domain','level','span') + { + if($at{$arg}) { $new->setAttribute($arg,$at{$arg})} + } + if($at{'tech-domain'}) {&positionByTechDomain($new)} + } + &setHref($new,$contents); + print STDERR "$warning: Adding found $tag $id from $contents\n"; + delete $replacing{$tag}->{$fullid}; + } + # newline after each new tag so output's not ugly + if($new->getNextSibling) + { + $node->insertBefore($doc->createTextNode ("\n"),$new->getNextSibling); + } + else + { + $node->appendChild($doc->createTextNode ("\n")); + } + delete $newContainer{$ppath}; + } + + +sub getNamespacePrefix + { + my $node = shift; + my $ns = shift; + my $root = $node->getOwnerDocument->getDocumentElement; + my $idns = $root->getAttribute("id-namespace"); + if($idns && $idns eq $ns) {return} + if(!$idns && $defaultns eq $ns) {return} + foreach my $a (keys %{$root->getAttributes}) + { + my $pre = $a; + if($pre=~s/^xmlns://) + { + if($node->getAttribute ($a) eq $ns) {return $pre} + } + } + die "ERROR: no namespace prefix defined for $ns"; + } + + +sub resolvePath + { + # return full path to 2nd arg relative to first (path or absolute URI) + my $base = shift; + my $path = shift; + if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it. + if($path=~s,^file:///([a-zA-Z]:/),$1,) {return $path } # file URI with drive letter + if($path=~m,^file://,) {return $path } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it + if($path=~m,^[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- no idea how to handle, so just return + return &abspath(File::Basename::dirname($base)."/$path"); + } + + +sub fixHref { + my $node = shift; + my $base = shift; + my $link= $node->getAttribute('href'); + if($link=~/^(ftp|http)s:\/\//) {return} # remote link, do nothing + my $path = &resolvePath($base,$link); + if(!-e $path) + { # no such file, delete + my $tag =$node->getTagName; + my $id = $node->getAttribute('id'); + print STDERR "$warning: $tag $id not found at $link\n"; + $node->getParentNode->removeChild($node); + return; + } + if($output eq '') + { + $path=~s,^/?,file:///,; + $node->setAttribute('href',$path); # replace with absolute URI + return; + } + $node->setAttribute('href',&normpath($modpath.$link)); # make relative path to output file + } + + +sub setHref { + my $node = shift; + my $file = shift; + if($output eq '') + { + $path = &abspath($file); + $path=~s,^/?,file:///,; + $node->setAttribute('href',$path); # replace with absolute URI + } + else + { + $node->setAttribute('href',&relativeTo(&abspath($output),$file,'file')); + } +} + + +sub relativeTo { + if($_[0] eq '') {return &abspath($_[1])} + my @outfile = split(/[\\\/]/,lc(shift)); + my @infile = split(/[\\\/]/,lc(shift)); + my $asdir = shift ne 'file'; + while($outfile[0] eq $infile[0]) + { + shift(@outfile); + shift(@infile); + } + $modpath = '../' x (scalar(@outfile) - 1); + if($asdir) { + if(scalar @infile > 1) {$modpath .= join('/',@infile[0..$#infile - 1]).'/'} + } else {$modpath .= join('/',@infile)} + return $modpath; +} + +sub positionByTechDomain + { + my $node=shift; + my $td = $node->getAttribute('tech-domain'); + my %before; + foreach my $t (@tdOrder) + { + $before{$t}=1; + if($t eq $td) {last} + } + my $prev = $node->getPreviousSibling; + foreach my $child (reverse @{$node->getParentNode->getChildNodes}) + { + if($child->getNodeType==1 && $child->getTagName eq 'package' && $child!=$node) + { + if($before{$child->getAttribute('tech-domain')}) + { + my $next = $child->getNextSibling; + while($next && $next->getNodeType!=1) {$next = $next->getNextSibling} + if($next) { + $node->getParentNode->insertBefore ($node,$next); + } + last; + } + } + } + } diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/sysdefdowngrade.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/sysdefdowngrade.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,425 @@ + + + + + + os/deviceplatformrelease/foundation_system/system_model + + + + + + + ERROR: Cannot process this document + + + + + + + + + + + + + + + + + + + + ERROR: Package definition () cannot link another package + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ERROR: Package IDs do not match: vs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WARNING: Excessive nesting of packages: Ignoring + + + + + + + + + + + + + + + + + + + + + Y + + + plugin + + placeholder + PC + + + + + + + + + + + + + + + + + + + + + + + Y + N + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> +]]> + + diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/validate/checklinks.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/validate/checklinks.pl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,108 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Script to validate the unit links in a system definition or package definition XML file + +use strict; + +if (! scalar @ARGV) {&help()} + + +my $debug = 0; +my $skipfilter; # skip anything with a named filter +my $xslt = "../../../buildtools/bldsystemtools/buildsystemtools/joinsysdef.xsl"; +my $xalan = "../../../buildtools/devlib/devlibhelp/tools/doc_tree/lib/apache/xalan.jar"; +my $sysdef = shift; +while($sysdef=~/^-/) { #arguments + if($sysdef eq '-nofilter') {$skipfilter = shift} + elsif($sysdef eq '-v') {$debug = 1} + else { &help("Invalid command line option $sysdef")} + $sysdef = shift; +} +my $dir = $sysdef; +$dir =~ s,[^\\/]+$,,; +my $root="../../../.."; + my $full; + +if($sysdef=~/system_definition\.xml/) { # if running on a sysdef, ensure it's joined before continuing + ($full = `java -jar $dir$xalan -in $sysdef -xsl $dir$xslt`) || die "bad XML syntax"; +}else { # assume any other file has no hrefs to include (valid by convention) + $root=''; + open S, $sysdef; + $full=join('',); + close S; +} +$full=~s///sg; # remove all comments; +my $count=1; + +my $filter = ''; +foreach (split(/ + + + + + + Cross-Checking System Model + + + + + + + + +

+ ()

+
+ + +

+ Note: + + + ()

+
+ + +

+ Warning: + + + ()

+
+ + +

+ Error: + + + ()

+
+ + \ No newline at end of file diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/validate/test-model.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/validate/test-model.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,490 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + System Definition: + items + + + + + + + + + + + + Definition: + units + + + + systemModel element should have a name + + + + + + + + + Attribute ="" is not valid for + + + + + + + + + + + plugin + doc + tool + config + api + test + + + + mandatory + optional + development + + + other + desktop + device + + + + + lo + hb + mm + ma + pr + vc + se + ui + dc + de + dm + rt + to + ocp + + + + + + + + + + + + + + + + + + + + + Illegal value ="" + + + + value in ="" + + + + + + + + + + + + + + + + + Illegal value ="" + + + + value in ="" + + + + + + + + + + Element "" is not valid in the context of "" + + + + "" has invalid parent "" + + + + + + + + + + + S60 Component "" has children. + + + Component "" has children. + + + + + + + Component "" is empty. + + + Component "" is empty and has no comment + + + + + + + "" must match ID in linked file "" + + + linked "" cannot be a link + + + + linked "" has duplicate attribute to linking document. Duplicate ignored. + + + + "" cannot have both link and content. Content ignored. + + + + "" must match item in linked file "" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Duplicate ID: "" + + + + Undefined namespace for ID "" + + + + + + + + + + + + + + + + + + + + + // + / + + + + + + + + + + + + + + + + + + + + + + + Unexpected path for -> "" + + + + + + + Unexpected path for -> "" + + + Unexpected path for -> "" + + + Unexpected path for -> "" + + + + + + path "" should not end in / + + + path "" must use only forward slashes + + + + + + + + + + + has no match in . + + + + + + + : + + + + + + + + + + + not identical. [|] + + + + + + + + + + + + not identical. [|] + + + + () + + +vp cross-check + + + + + + + + + VP component "" v not in SysDef + + + + + + + Found + Found + + + + + + + + + + + + + +System Build cross-check + + + + + + + + Build item "" not in SysDef + + + + + + Build list "" not defined + + + + + + + + + + + () + () + (? - ) + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + \ No newline at end of file diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/validate/validate-sysdef.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdeftools/validate/validate-sysdef.xsl Tue Apr 06 10:25:29 2010 +0100 @@ -0,0 +1,48 @@ + + + + + + + + + + () + + + + + + Note: + + () + + + + + + Warning: + + () + + + + + Error: + + () + + + \ No newline at end of file diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/xalan.jar Binary file sysdeftools/xalan.jar has changed diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/xercesImpl.jar Binary file sysdeftools/xercesImpl.jar has changed diff -r 8d58b930d36e -r 84b123918d3f sysdeftools/xml-apis.jar Binary file sysdeftools/xml-apis.jar has changed