Changeset 1488


Ignore:
Timestamp:
08/21/11 20:31:13 (13 years ago)
Author:
vronk
Message:

output - method, DOCTYPE, encoding issues (trying to unify for xhtml (but not over all xsls yet); test-suite update

Location:
MDService2/trunk/MDService2
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r1481 r1488  
    9393                                // TODO Auto-generated catch block
    9494                                e.printStackTrace();
     95                        } catch (NoStylesheetException e) {
     96                                // TODO Auto-generated catch block
     97                                e.printStackTrace();
    9598                        }
    9699         }
     
    196199        public String getActionContentType() {
    197200                if (format.toLowerCase().startsWith("html")) {
    198                         this.actionContentType = "text/html";
     201                        this.actionContentType = "text/html";           
     202                        //this.actionContentType = "application/xhtml+xml";
    199203                } else {
    200204                        this.actionContentType = "text/xml";
     
    408412                        return key;
    409413        }
    410         public InputStream getSourceStream() throws IOException {               
     414        public InputStream getSourceStream() throws IOException, NoStylesheetException {               
    411415                return getTargetRequest().openStream();
    412416                //      Admin.notifyUser(getProxyKey() + ".getSourceStream() - unable to open stream: " + getTargetRequest(); 
     
    446450
    447451       
    448         public static JSONArray createRepositories() throws IOException, InterruptedException, TransformerException{
     452        public static JSONArray createRepositories() throws IOException, InterruptedException, TransformerException, NoStylesheetException{
    449453                String path = Admin.getConfig().getProperty("workspaceprofile.path") + WorkspaceAction.WORKSPACE_FILENAME;//PROFILENAME_SERVER;
    450454                File file=new File(path);
     
    452456               
    453457                MDTransformer transformer = new MDTransformer();
    454                 transformer.setSrcFile(file.toURL());
     458                transformer.setSrcFile(file.toURI().toURL());
    455459                transformer.setParams(MDTransformer.createParamsMap("xml2json"));
    456460                InputStream jsonstream = transformer.transformXML(in);
     
    497501                                // TODO Auto-generated catch block
    498502                                e.printStackTrace();
     503                        } catch (NoStylesheetException e) {
     504                                // TODO Auto-generated catch block
     505                                e.printStackTrace();
    499506                        }
    500507                }
     
    536543                                e.printStackTrace();
    537544                        } catch (TransformerException e) {
     545                                // TODO Auto-generated catch block
     546                                e.printStackTrace();
     547                        } catch (NoStylesheetException e) {
    538548                                // TODO Auto-generated catch block
    539549                                e.printStackTrace();
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java

    r1431 r1488  
    101101         * @param key
    102102         * @return
    103          */
    104         private String getXSLPath (String key) {               
     103         * @throws NoStylesheetException - if no matching entry in properties could be found
     104         */
     105        private String getXSLPath (String key) throws NoStylesheetException {           
    105106                String xslpath = "";
    106107                String xslfilename= Admin.getConfig().getProperty("xsl." + key);
     
    108109                if (xslfilename!=null) {                       
    109110                        xslpath =  Admin.getConfig().getProperty("scripts.path") + xslfilename;
    110                 }
     111                } else {
     112                        throw new NoStylesheetException("No Stylesheet found for format-key: " + key);
     113                }
    111114                Admin.notifyUser("xslfile:" + xslpath);
    112115                return xslpath;
    113116        }
    114117
    115         private StreamSource getXSLStreamSource (String key){           
     118        private StreamSource getXSLStreamSource (String key) throws NoStylesheetException{             
    116119               
    117120                InputStream xslstream;
     
    206209         * @throws TransformerException
    207210         * @throws IOException
    208          */
    209         public void transformXML (InputStream in, OutputStream out ) throws TransformerException, IOException {
     211         * @throws NoStylesheetException
     212         */
     213        public void transformXML (InputStream in, OutputStream out ) throws TransformerException, IOException, NoStylesheetException {
    210214        //public void transformXML (InputStream in, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q, String repositoryURI, OutputStream out ) throws TransformerException, IOException {
    211215       
     
    310314         * @throws InterruptedException
    311315         * @throws TransformerException
    312          */
    313         public InputStream transformXML ( InputStream xmlStream) throws IOException, InterruptedException, TransformerException {
     316         * @throws NoStylesheetException
     317         */
     318        public InputStream transformXML ( InputStream xmlStream) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
    314319        //public InputStream transformXML ( InputStream xmlStream, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q, String repositoryURI) throws IOException, InterruptedException, TransformerException {
    315320               
     
    348353         * @throws TransformerException
    349354         * @throws IOException
    350          */
    351         public InputStream transformXML (URL xmlFile ) throws IOException, InterruptedException, TransformerException {
     355         * @throws NoStylesheetException
     356         */
     357        public InputStream transformXML (URL xmlFile ) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
    352358        //public InputStream transformXML (URL xmlFile, String transkey ) throws IOException, InterruptedException, TransformerException {
    353359                srcFile= xmlFile;
     
    365371         * @param transkey
    366372         * @return
     373         * @throws NoStylesheetException
    367374         * @throws IOException
    368375         */
    369         public String transformXML (String xml) {
     376        public String transformXML (String xml) throws NoStylesheetException {
    370377        //public String transformXML (String xml, String transkey ) {
    371378                String result="";
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Pz2ProxyAction.java

    r1486 r1488  
    137137
    138138        @Override
    139         public InputStream getSourceStream() throws IOException {
     139        public InputStream getSourceStream() throws IOException, NoStylesheetException {
    140140                if (getCommand() == null){
    141141                        try {
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/TermsProxyAction.java

    r1268 r1488  
    128128        }
    129129       
    130         public InputStream getSourceStream() throws IOException{
     130        public InputStream getSourceStream() throws IOException, NoStylesheetException{
    131131                String type = getTSAttr("type");
    132132                Admin.notifyUser("TPA.getSourceStream.TStype: " + type);
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Query.java

    r1455 r1488  
    2828import eu.clarin.cmdi.mdservice.action.Admin;
    2929import eu.clarin.cmdi.mdservice.action.MDTransformer;
     30import eu.clarin.cmdi.mdservice.action.NoStylesheetException;
    3031
    3132public class Query {   
     
    477478                MDTransformer transformer = new MDTransformer();
    478479                transformer.setParams(MDTransformer.createParamsMap("XCQL2XPATH"));
    479                 return transformer.transformXML(toXCQL());
     480                try {
     481                        return transformer.transformXML(toXCQL());
     482                } catch (NoStylesheetException e) {
     483                        setMsg("Query.toXPath-"+ e.getClass() + ": " + e.getMessage());
     484                        return "";
     485                }
    480486        }
    481487
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Result.java

    r911 r1488  
    88import eu.clarin.cmdi.mdservice.action.Admin;
    99import eu.clarin.cmdi.mdservice.action.MDTransformer;
     10import eu.clarin.cmdi.mdservice.action.NoStylesheetException;
    1011
    1112/**
     
    4950         * @throws InterruptedException
    5051         * @throws TransformerException
     52         * @throws NoStylesheetException
    5153         */
    52         public InputStream getResultStream(String format) throws IOException, InterruptedException, TransformerException {
     54        public InputStream getResultStream(String format) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
    5355                String transformkey;
    5456               
     
    7274        }
    7375
    74         public void getResultStream(String format, InputStream in) throws IOException, InterruptedException, TransformerException {
     76        public void getResultStream(String format, InputStream in) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
    7577                        in = getResultStream(format);
    7678        }
  • MDService2/trunk/MDService2/src/struts.xml

    r1484 r1488  
    1414                <global-results>
    1515                            <!-- <result name="exception">/Exception.jsp</result>-->
    16                             <result name="exception">/ExceptionXML.jsp</result>
     16                            <result name="exception">/ExceptionXML.jsp</result>
     17                            <result name="nostylesheet-exception">/ExceptionNoStylesheet.jsp</result>
     18                                <result name="repositorydown-exception">/ExceptionXMLRepositoryDown.jsp</result>
    1719                            <!-- tried setting html-status, didn't work: 
    1820                                <result name="exception">
     
    2729        <global-exception-mappings>
    2830            <exception-mapping exception="java.lang.Exception" result="exception"/>
     31            <exception-mapping exception="eu.clarin.cmdi.mdservice.action.NoStylesheetException" result="nostylesheet-exception"/>
     32            <exception-mapping exception="java.io.IOException" result="repositorydown-exception"/>
     33           
    2934        </global-exception-mappings>
    3035
     
    182187                           <param name="actionkey"></param>
    183188                            <result type="stream">                         
    184                                 <param name="contentType">json</param>
     189                                <param name="contentType">application/json</param>
    185190                                <param name="inputName">resultStream</param>                           
    186191                            </result>
  • MDService2/trunk/MDService2/src/xsl/cmd_commons.xsl

    r1479 r1488  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8" ?>
    22<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    3  xmlns:my="myFunctions">
     3 xmlns:my="myFunctions"
     4 exclude-result-prefixes="my">
    45
    56<!--
     
    5556<xsl:template name="html">
    5657
    57         <html>
     58        <html xmlns="http://www.w3.org/1999/xhtml" >
    5859        <head>
     60       
    5961        <title><xsl:value-of select="$title"/></title>
    6062
     
    9395        <head>
    9496                <title><xsl:value-of select="$title"/></title>
    95                 <!-- <xsl:call-template name="callback-header"/> -->   
     97                <link href="{$base_dir}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link>
     98                <!-- <xsl:call-template name="callback-header"/> -->
     99                       
    96100        </head>
    97101        <body>
  • MDService2/trunk/MDService2/src/xsl/mdinst2view.xsl

    r1226 r1488  
    5454                        <xsl:when test="contains($format,'htmlpage')">
    5555                                <h3><xsl:value-of select="$inner_title" /></h3>
     56                                <xsl:call-template name="getContext" />
    5657                        </xsl:when>     
    5758                        <xsl:otherwise>
  • MDService2/trunk/MDService2/src/xsl/mdset2view.xsl

    r1417 r1488  
    1 <?xml version="1.0" encoding="utf-8"?>
     1<?xml version="1.0" encoding="utf-8" ?>
    22<xsl:stylesheet
    33  version="2.0"
     
    55  xmlns:xs="http://www.w3.org/2001/XMLSchema"
    66  xmlns:saxon="http://saxon.sf.net/"
    7   xmlns:my="myFunctions"
     7  xmlns:my="myFunctions"
     8  exclude-result-prefixes="saxon my xs"
    89>
    910<!--
     
    1920<xsl:import href="terms2view.xsl"/>
    2021
    21 <xsl:output method="html" />
     22<xsl:output method="xhtml" media-type="application/xhtml+xml" indent="yes" encoding="UTF-8"
     23doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
     24
     25  <!--
     26  if this is added  to the output-element, it terribly slows down requests with recordset being injected via document() function
     27   (like: http://localhost:8080/MDService2/docs/htmlpagetest/queries2)
     28  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /> 
     29  -->
    2230
    2331<xsl:include href="cmd_commons.xsl"/>
     
    7785
    7886<xsl:for-each select="searchRetrieveResponse" >
     87<div>
    7988        <xsl:if test="not(contains($format, 'htmlsimple'))">
    8089                <xsl:call-template name="header" />
     
    101110                                <xsl:otherwise>mdset2view: unrecognized format: <xsl:value-of select="$format" /></xsl:otherwise>
    102111        </xsl:choose>
     112        </div>
    103113</xsl:for-each>
    104114       
     
    373383                                <label> maxItems: </label><input type="text" name="maximumItems" ><xsl:attribute name="value"><xsl:value-of select="$maximumItems"/></xsl:attribute> </input>
    374384        </form>
     385        <xsl:call-template name="header" />     
    375386        <table class="show">           
    376387                <thead><tr><th>pos</th>         
  • MDService2/trunk/MDService2/src/xsl/test2view.xsl

    r1423 r1488  
    99</params>
    1010<history>
    11         <change on="2010-11-12" type="created" by="vr">based on xml2htmltable</change> 
     11        <change on="2011-05-23" type="created" by="vr">based on xml2htmltable</change> 
    1212       
    1313</history>
     
    2929 <div class="cmds-ui-block" >
    3030         <div class="ui-widget-header">
    31                 <xsl:value-of select="@class" />: <xsl:copy-of select="." /> [<xsl:value-of select="@href" />]
     31                <xsl:value-of select="@class" />: <xsl:copy-of select="." /> [<a href="{concat($base_url,@href)}" ><xsl:value-of select="@href" /></a>]
    3232        </div> 
     33       
    3334        <div class="ui-widget-content">
    3435                <xsl:choose>
    35                         <xsl:when test="@class='count'">
     36                        <xsl:when test="@class='requestcount'">
    3637                                        <xsl:variable name="data" select="document(concat($base_url,@href))" />
    3738                                        <xsl:value-of select="count($data//*)" />
    3839                        </xsl:when>
    39                         <xsl:when test="@class='queryxml'">
    40                                         <xsl:variable name="data" select="document(concat($base_url,@href))" />
     40                        <xsl:when test="@class='query'">
     41                                        <xsl:variable name="data" select="document(concat($base_url,'recordset/htmltable/', @href))" />
     42                                        <xsl:copy-of select="$data" />
     43                        </xsl:when>
     44                        <xsl:when test="@class='query count'">
     45                                        <xsl:variable name="data" select="document(concat($base_url,'recordset/xml/', @href))" />
    4146                                        <xsl:value-of select="$data//numberOfRecords" />
    4247                        </xsl:when>
     
    4449                                        <xsl:apply-templates select="document(concat($base_url,@href))" mode="process-query"/>
    4550                        </xsl:otherwise>
    46                 </xsl:choose>           
     51                </xsl:choose>
     52                               
    4753        </div>
    4854 </div>
Note: See TracChangeset for help on using the changeset viewer.