Changeset 7478


Ignore:
Timestamp:
11/23/06 22:24:42 (5 years ago)
Author:
sys
Message:

Implementation api IData.getNode()

Location:
trunk/Jav_CO/com/scenari/m/co/donnee
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_CO/com/scenari/m/co/donnee/HADonneeMgr.java

    r7458 r7478  
    4949import com.scenari.s.fw.log.HLogMgr; 
    5050 
    51  
    5251/** 
    5352 *  
     
    5655 
    5756        public static final String TYPE_FIXE = "fixe"; 
     57 
    5858        public static final String TYPE_FIXE_ALIAS = "fixe-alias"; 
     59 
    5960        public static final String TYPE_FIXE_SYSTEM_PROPS = "fixe-systemProperties"; 
     61 
     62        public static final String TYPE_FIXE_NODE = "fixe-node"; 
     63 
    6064        public static final String TYPE_XPATH_STATIQUE = "xpath-statique"; 
     65 
    6166        public static final String TYPE_XPATH_DYNAMIQUE = "xpath-dynamique"; 
     67 
    6268        public static final String TYPE_XPATH_DOUBLE = "xpath-double"; 
     69 
    6370        public static final String TYPE_XPATHONSRC_DYNAMIQUE = "xpathOnSrc-dynamique"; 
     71 
    6472        public static final String TYPE_EXTRAIT_XML_STATIQUE = "extraitxml-statique"; 
     73 
    6574        public static final String TYPE_XSL_STATIQUE = "xsl-statique"; 
     75 
    6676        public static final String TYPE_XSL_DYNAMIQUE = "xsl-dynamique"; 
     77 
    6778        public static final String TYPE_XSL_DOUBLE = "xsl-double"; 
     79 
    6880        public static final String TYPE_XSL_MONOTEMPLATE = "xsl-monotemplate"; 
     81 
    6982        public static final String TYPE_XSL_XPATH = "xsl-xpath"; 
     83 
    7084        public static final String TYPE_XSL_BEANSHELL = "xsl-beanshell"; 
     85 
    7186        public static final String TYPE_XSL_WEBMACRO = "xsl-webmacro"; 
     87 
    7288        public static final String TYPE_XSLONSRC_DYNAMIQUE = "xslOnSrc-dynamique"; 
     89 
    7390        public static final String TYPE_COMPOSITION_DYNAMIQUE = "composition-dynamique"; 
     91 
    7492        public static final String TYPE_CONTEXTUEL_DYNAMIQUE = "contextuel-dynamique"; 
     93 
    7594        public static final String TYPE_WEBMACRO_DYNAMIQUE = "webmacro-dynamique"; 
     95 
    7696        public static final String TYPE_RESULTAT_DYNAMIQUE = "resultat-dynamique"; 
     97 
    7798        public static final String TYPE_INCLUSION_DYNAMIQUE = "inclusion-dynamique"; 
    78     public static final String TYPE_INCLUSIONTEXT_DYNAMIQUE = "inclusionText-dynamique"; 
    79          
     99 
     100        public static final String TYPE_INCLUSIONTEXT_DYNAMIQUE = "inclusionText-dynamique"; 
     101 
    80102        public static Map sTypesDonneesSuppl = new HashMap(); 
    81 /** 
    82  *  
    83  */ 
    84 public HADonneeMgr() { 
    85         super(); 
     103 
     104        /** 
     105         *  
     106         */ 
     107        public HADonneeMgr() { 
     108                super(); 
     109        } 
     110 
     111        /** 
     112         * Permet d'ajouter des type de données ne faisant pas partie du coeur de Scenari. 
     113         *  
     114         * @param pType java.lang.String 
     115         * @param pClass java.lang.Class 
     116         */ 
     117        public static final void hAddTypeDonnee(String pType, Class pClass) { 
     118                sTypesDonneesSuppl.put(pType, pClass); 
     119        } 
     120 
     121        /** 
     122         * Crée une donnée du bon type. 
     123         * Attention : il faudra passer sa définition ultérieurement  
     124         * par les méthodes IWADonnee.hSetValue(String) ou IWADonnee.hSetValueParRef(String) 
     125         *  
     126         * @return com.scenari.m.co.donnee.IWADonnee 
     127         * @param pType Type de donnée. 
     128         * @param pMimeType Mime-type de donnée produite. 
     129         * @param pCompType com.scenari.m.co.composant.IHComposantType 
     130         */ 
     131 
     132        public static final IAgentData hNewDonnee(String pType, String pMimeType, IHComposantType pCompType) throws Exception { 
     133 
     134                return xNewDonnee(pType, pMimeType, pCompType, false); 
     135        } 
     136 
     137        /** 
     138         * Crée une donnée du bon type avec sa définition. 
     139         * pUrlBase donne le chemin courant dans l'espace de publication où la donnée 
     140         * est déclarée. 
     141         *  
     142         * @return com.scenari.m.co.donnee.IWADonnee 
     143         * @param pType Type de donnée. 
     144         * @param pMimeType Mime-type de donnée produite. 
     145         * @param pCompType com.scenari.m.co.composant.IHComposantType 
     146         * @param pDefinition Contenu de la donnée. 
     147         * @param pContextDonnee Contexte courant à partir duquel la donnée est créée (utile si la donnée fait référence à des ressources externes). 
     148         */ 
     149        public static final IAgentData hNewDonnee(String pType, String pMimeType, IHComposantType pCompType, String pDefinition, IHContextDonnee pContextDonnee) throws Exception { 
     150 
     151                IAgentData vDonnee = xNewDonnee(pType, pMimeType, pCompType, false); 
     152 
     153                vDonnee.wSetValue(pCompType, pDefinition, pContextDonnee); 
     154 
     155                return vDonnee; 
     156        } 
     157 
     158        /** 
     159         * Crée une donnée du bon type en cherchant sa définition dans la 
     160         * ressource pDocSource. 
     161         *  
     162         * @return com.scenari.m.co.donnee.IWADonnee 
     163         * @param pType Type de donnée. 
     164         * @param pMimeType Mime-type de donnée produite. 
     165         * @param pCompType com.scenari.m.co.composant.IHComposantType 
     166         * @param pDocSource document source contenant la donnée. 
     167         */ 
     168        public static final IAgentData hNewDonneeParRef(String pType, String pMimeType, IHComposantType pCompType, IHSource pDocSource) throws Exception { 
     169 
     170                IAgentData vDonnee = xNewDonnee(pType, pMimeType, pCompType, true); 
     171                vDonnee.wSetValueParRef(pCompType, pDocSource); 
     172 
     173                return vDonnee; 
     174        } 
     175 
     176        /** 
     177         * Crée une donnée du bon type. 
     178         * Attention : il faudra passer sa définition ultérieurement  
     179         * par les méthodes IWADonnee.hSetValue(String) ou IWADonnee.hSetValueParRef(String) 
     180         *  
     181         * @return Donnee créée. 
     182         * @param pType Type de la donnée. 
     183         * @param pCompType Composant type de la donnée. 
     184         * @param pParRef Vrai si l'affectation se fait par undocSource externe. 
     185         */ 
     186        private static final IAgentData xNewDonnee(String pType, String pMimeType, IHComposantType pCompType, boolean pParRef) throws Exception { 
     187 
     188                IAgentData vDonnee = null; 
     189 
     190                if (pType == null || pType.equals(TYPE_FIXE) || pType.equals("")) { 
     191                        vDonnee = new WDonneeFixe(); 
     192                } else if (pType.equals(TYPE_FIXE_ALIAS)) { 
     193                        vDonnee = new WDonneeFixeAlias(); 
     194                } else if (pType.equals(TYPE_FIXE_SYSTEM_PROPS)) { 
     195                        vDonnee = new WDonneeFixeSystemProps(); 
     196                } else if (pType.equals(TYPE_XSL_STATIQUE)) { 
     197                        vDonnee = new WDonneeXslStatique(); 
     198                } else if (pType.equals(TYPE_XSL_DYNAMIQUE)) { 
     199                        vDonnee = new WDonneeXslDynamique(); 
     200                } else if (pType.equals(TYPE_XSL_MONOTEMPLATE)) { 
     201                        vDonnee = new WDonneeXslMonoTemplate(); 
     202                } else if (pType.equals(TYPE_XSL_DOUBLE)) { 
     203                        vDonnee = new WDonneeXslDouble(); 
     204                } else if (pType.equals(TYPE_XPATH_STATIQUE)) { 
     205                        vDonnee = new WDonneeXPathStatique(); 
     206                } else if (pType.equals(TYPE_XPATH_DYNAMIQUE)) { 
     207                        vDonnee = new WDonneeXPathDynamique(); 
     208                } else if (pType.equals(TYPE_XPATHONSRC_DYNAMIQUE)) { 
     209                        vDonnee = new WDonneeXPathOnSrcDynamique(); 
     210                } else if (pType.equals(TYPE_XPATH_DOUBLE)) { 
     211                        vDonnee = new WDonneeXPathDouble(); 
     212                } else if (pType.equals(TYPE_EXTRAIT_XML_STATIQUE)) { 
     213                        vDonnee = new WDonneeXPathXmlExtract(); 
     214                } else if (pType.equals(TYPE_XSL_XPATH)) { 
     215                        vDonnee = new WDonneeXslXPath(); 
     216                } else if (pType.equals(TYPE_XSL_WEBMACRO)) { 
     217                        vDonnee = new WDonneeXslWebMacro(); 
     218                } else if (pType.equals(TYPE_XSLONSRC_DYNAMIQUE)) { 
     219                        vDonnee = new WDonneeXslOnSrcDynamique(); 
     220                } else if (pType.equals(TYPE_RESULTAT_DYNAMIQUE)) { 
     221                        vDonnee = new WDonneeResultatDynamique(); 
     222                } else if (pType.equals(TYPE_COMPOSITION_DYNAMIQUE)) { 
     223                        vDonnee = new WDonneeComposition(); 
     224                } else if (pType.equals(TYPE_CONTEXTUEL_DYNAMIQUE)) { 
     225                        vDonnee = new WDonneeContextuelDynamique(); 
     226                } else if (pType.equals(TYPE_WEBMACRO_DYNAMIQUE)) { 
     227                        vDonnee = new WDonneeWebMacroDynamique(); 
     228                } else if (pType.equals(TYPE_INCLUSION_DYNAMIQUE)) { 
     229                        vDonnee = new WDonneeInclusionDynamique(true); 
     230                } else if (pType.equals(TYPE_INCLUSIONTEXT_DYNAMIQUE)) { 
     231                        vDonnee = new WDonneeInclusionDynamique(false); 
     232                } else if (pType.equals(TYPE_FIXE_NODE)) { 
     233                        vDonnee = new WDonneeNodeFix(); 
     234                } else { 
     235                        Class vClass = (Class) sTypesDonneesSuppl.get(pType); 
     236                        if (vClass != null) { 
     237                                vDonnee = (IAgentData) vClass.newInstance(); 
     238                        } else { 
     239                                throw HLogMgr.hNewException("Le type de donnée '" + pType + " déclaré dans le composant type '" + pCompType + "' est inconnu."); 
     240                        } 
     241                } 
     242 
     243                vDonnee.wSetMime(pMimeType); 
     244 
     245                return vDonnee; 
     246        } 
    86247} 
    87 /** 
    88  * Permet d'ajouter des type de données ne faisant pas partie du coeur de Scenari. 
    89  *  
    90  * @param pType java.lang.String 
    91  * @param pClass java.lang.Class 
    92  */ 
    93 public static final void hAddTypeDonnee(String pType, Class pClass) { 
    94         sTypesDonneesSuppl.put(pType, pClass);   
    95 } 
    96 /** 
    97  * Crée une donnée du bon type. 
    98  * Attention : il faudra passer sa définition ultérieurement  
    99  * par les méthodes IWADonnee.hSetValue(String) ou IWADonnee.hSetValueParRef(String) 
    100  *  
    101  * @return com.scenari.m.co.donnee.IWADonnee 
    102  * @param pType Type de donnée. 
    103  * @param pMimeType Mime-type de donnée produite. 
    104  * @param pCompType com.scenari.m.co.composant.IHComposantType 
    105  */ 
    106  
    107 public static final IAgentData hNewDonnee(String pType, String pMimeType, IHComposantType pCompType) throws Exception { 
    108  
    109         return xNewDonnee(pType, pMimeType, pCompType, false); 
    110 } 
    111 /** 
    112  * Crée une donnée du bon type avec sa définition. 
    113  * pUrlBase donne le chemin courant dans l'espace de publication où la donnée 
    114  * est déclarée. 
    115  *  
    116  * @return com.scenari.m.co.donnee.IWADonnee 
    117  * @param pType Type de donnée. 
    118  * @param pMimeType Mime-type de donnée produite. 
    119  * @param pCompType com.scenari.m.co.composant.IHComposantType 
    120  * @param pDefinition Contenu de la donnée. 
    121  * @param pContextDonnee Contexte courant à partir duquel la donnée est créée (utile si la donnée fait référence à des ressources externes). 
    122  */ 
    123 public static final IAgentData hNewDonnee(String pType, String pMimeType, IHComposantType pCompType, String pDefinition, IHContextDonnee pContextDonnee) throws Exception { 
    124  
    125         IAgentData vDonnee = xNewDonnee(pType, pMimeType, pCompType, false); 
    126  
    127         vDonnee.wSetValue(pCompType, pDefinition, pContextDonnee); 
    128                          
    129         return vDonnee; 
    130 } 
    131 /** 
    132  * Crée une donnée du bon type en cherchant sa définition dans la 
    133  * ressource pDocSource. 
    134  *  
    135  * @return com.scenari.m.co.donnee.IWADonnee 
    136  * @param pType Type de donnée. 
    137  * @param pMimeType Mime-type de donnée produite. 
    138  * @param pCompType com.scenari.m.co.composant.IHComposantType 
    139  * @param pDocSource document source contenant la donnée. 
    140  */ 
    141 public static final IAgentData hNewDonneeParRef(String pType, String pMimeType, IHComposantType pCompType, IHSource pDocSource) throws Exception { 
    142  
    143         IAgentData vDonnee = xNewDonnee(pType, pMimeType, pCompType, true); 
    144         vDonnee.wSetValueParRef(pCompType, pDocSource); 
    145          
    146         return vDonnee; 
    147 } 
    148 /** 
    149  * Crée une donnée du bon type. 
    150  * Attention : il faudra passer sa définition ultérieurement  
    151  * par les méthodes IWADonnee.hSetValue(String) ou IWADonnee.hSetValueParRef(String) 
    152  *  
    153  * @return Donnee créée. 
    154  * @param pType Type de la donnée. 
    155  * @param pCompType Composant type de la donnée. 
    156  * @param pParRef Vrai si l'affectation se fait par undocSource externe. 
    157  */ 
    158 private static final IAgentData xNewDonnee(String pType, String pMimeType, IHComposantType pCompType, boolean pParRef) throws Exception { 
    159  
    160         IAgentData vDonnee = null; 
    161  
    162         if (pType == null || pType.equals(TYPE_FIXE) || pType.equals("")) { 
    163                 vDonnee = new WDonneeFixe(); 
    164         } else if (pType.equals(TYPE_FIXE_ALIAS)) { 
    165                 vDonnee = new WDonneeFixeAlias(); 
    166         }  else if (pType.equals(TYPE_FIXE_SYSTEM_PROPS)) { 
    167                         vDonnee = new WDonneeFixeSystemProps(); 
    168         } else if (pType.equals(TYPE_XSL_STATIQUE)) { 
    169                 vDonnee = new WDonneeXslStatique(); 
    170         } else if (pType.equals(TYPE_XSL_DYNAMIQUE)) { 
    171                 vDonnee = new WDonneeXslDynamique(); 
    172         } else if (pType.equals(TYPE_XSL_MONOTEMPLATE)) { 
    173                 vDonnee = new WDonneeXslMonoTemplate(); 
    174         } else if (pType.equals(TYPE_XSL_DOUBLE)) { 
    175                 vDonnee = new WDonneeXslDouble(); 
    176         } else if (pType.equals(TYPE_XPATH_STATIQUE)) { 
    177                 vDonnee = new WDonneeXPathStatique(); 
    178         } else if (pType.equals(TYPE_XPATH_DYNAMIQUE)) { 
    179                 vDonnee = new WDonneeXPathDynamique(); 
    180         } else if (pType.equals(TYPE_XPATHONSRC_DYNAMIQUE)) { 
    181                 vDonnee = new WDonneeXPathOnSrcDynamique(); 
    182         } else if (pType.equals(TYPE_XPATH_DOUBLE)) { 
    183                 vDonnee = new WDonneeXPathDouble(); 
    184         } else if (pType.equals(TYPE_EXTRAIT_XML_STATIQUE)) { 
    185                 vDonnee = new WDonneeXPathXmlExtract(); 
    186         } else if (pType.equals(TYPE_XSL_XPATH)) { 
    187                 vDonnee = new WDonneeXslXPath(); 
    188         } else if (pType.equals(TYPE_XSL_WEBMACRO)) { 
    189                 vDonnee = new WDonneeXslWebMacro(); 
    190         } else if (pType.equals(TYPE_XSLONSRC_DYNAMIQUE)) { 
    191                 vDonnee = new WDonneeXslOnSrcDynamique(); 
    192         } else if (pType.equals(TYPE_RESULTAT_DYNAMIQUE)) { 
    193                 vDonnee = new WDonneeResultatDynamique(); 
    194         } else if (pType.equals(TYPE_COMPOSITION_DYNAMIQUE)) { 
    195                 vDonnee = new WDonneeComposition(); 
    196         } else if (pType.equals(TYPE_CONTEXTUEL_DYNAMIQUE)) { 
    197                 vDonnee = new WDonneeContextuelDynamique(); 
    198         } else if (pType.equals(TYPE_WEBMACRO_DYNAMIQUE)) { 
    199                 vDonnee = new WDonneeWebMacroDynamique(); 
    200         } else if (pType.equals(TYPE_INCLUSION_DYNAMIQUE)) { 
    201                 vDonnee = new WDonneeInclusionDynamique(true); 
    202         } else if (pType.equals(TYPE_INCLUSIONTEXT_DYNAMIQUE)) { 
    203         vDonnee = new WDonneeInclusionDynamique(false); 
    204     } else { 
    205                 Class vClass = (Class)sTypesDonneesSuppl.get(pType); 
    206                 if(vClass != null) { 
    207                         vDonnee = (IAgentData)vClass.newInstance(); 
    208                 } else { 
    209                         throw HLogMgr.hNewException("Le type de donnée '" + pType + " déclaré dans le composant type '" + pCompType + "' est inconnu."); 
    210                 } 
    211         } 
    212  
    213         vDonnee.wSetMime(pMimeType); 
    214  
    215         return vDonnee; 
    216 } 
    217 } 
  • trunk/Jav_CO/com/scenari/m/co/donnee/HDonneeUtils.java

    r7458 r7478  
    4848import org.w3c.dom.DocumentFragment; 
    4949import org.w3c.dom.Node; 
     50import org.w3c.dom.traversal.NodeIterator; 
    5051import org.xml.sax.InputSource; 
    5152import org.xml.sax.SAXException; 
     
    7071 */ 
    7172public class HDonneeUtils { 
    72          
     73 
    7374        protected static final Properties OUTPUTPROPS_XML = new Properties(OutputProperties.getDefaultMethodProperties(Method.XML)); 
     75 
    7476        protected static final Properties OUTPUTPROPS_HTML = new Properties(OutputProperties.getDefaultMethodProperties(Method.HTML)); 
     77 
    7578        protected static final Properties OUTPUTPROPS_TEXT = new Properties(OutputProperties.getDefaultMethodProperties(Method.Text)); 
    7679        static { 
    7780                OUTPUTPROPS_XML.setProperty("omit-xml-declaration", "yes"); 
    7881        } 
     82 
    7983        protected static Properties getDefaultMethodProperties(String method) { 
    8084                if (method.equals(Method.XML)) { 
     
    8892                } 
    8993        } 
    90          
     94 
    9195        /** 
    9296         *  
     
    9599                super(); 
    96100        } 
    97          
     101 
    98102        /** 
    99103         * Transforme une valeur string en boolean en recherchant une représentation  
     
    104108         */ 
    105109        public static final boolean hGetBooleanEvalFalse(String pValue) { 
    106         if(pValue == null) return true; 
    107         final int vLen = pValue.length(); 
    108         if(vLen == 0) return true; 
    109         if(vLen == 1) return pValue.charAt(0)!='0'; 
    110         if(vLen == 5) { 
    111             char vChar = pValue.charAt(0); 
    112             if(vChar != 'f' && vChar != 'F') return true; 
    113             vChar = pValue.charAt(1); 
    114             if(vChar != 'a' && vChar != 'A') return true; 
    115             vChar = pValue.charAt(2); 
    116             if(vChar != 'l' && vChar != 'L') return true; 
    117             vChar = pValue.charAt(3); 
    118             if(vChar != 's' && vChar != 'S') return true; 
    119             vChar = pValue.charAt(4); 
    120             if(vChar == 'e' || vChar == 'E') return false; 
    121         } 
     110                if (pValue == null) return true; 
     111                final int vLen = pValue.length(); 
     112                if (vLen == 0) return true; 
     113                if (vLen == 1) return pValue.charAt(0) != '0'; 
     114                if (vLen == 5) { 
     115                        char vChar = pValue.charAt(0); 
     116                        if (vChar != 'f' && vChar != 'F') return true; 
     117                        vChar = pValue.charAt(1); 
     118                        if (vChar != 'a' && vChar != 'A') return true; 
     119                        vChar = pValue.charAt(2); 
     120                        if (vChar != 'l' && vChar != 'L') return true; 
     121                        vChar = pValue.charAt(3); 
     122                        if (vChar != 's' && vChar != 'S') return true; 
     123                        vChar = pValue.charAt(4); 
     124                        if (vChar == 'e' || vChar == 'E') return false; 
     125                } 
    122126                return true; 
    123127        } 
    124          
     128 
    125129        /** 
    126130         * Transforme une valeur string en boolean en recherchant une représentation  
     
    131135         */ 
    132136        public static final boolean hGetBooleanEvalTrue(String pValue) { 
    133         if(pValue == null) return false; 
    134         final int vLen = pValue.length(); 
    135         if(vLen == 0) return false; 
    136         if(vLen == 1) return pValue.charAt(0)=='1'; 
    137         if(vLen == 4) { 
    138             char vChar = pValue.charAt(0); 
    139             if(vChar != 't' && vChar != 'T') return false; 
    140             vChar = pValue.charAt(1); 
    141             if(vChar != 'r' && vChar != 'R') return false; 
    142             vChar = pValue.charAt(2); 
    143             if(vChar != 'u' && vChar != 'U') return false; 
    144             vChar = pValue.charAt(3); 
    145             if(vChar == 'e' || vChar == 'E') return true; 
    146         } 
    147         return false; 
     137                if (pValue == null) return false; 
     138                final int vLen = pValue.length(); 
     139                if (vLen == 0) return false; 
     140                if (vLen == 1) return pValue.charAt(0) == '1'; 
     141                if (vLen == 4) { 
     142                        char vChar = pValue.charAt(0); 
     143                        if (vChar != 't' && vChar != 'T') return false; 
     144                        vChar = pValue.charAt(1); 
     145                        if (vChar != 'r' && vChar != 'R') return false; 
     146                        vChar = pValue.charAt(2); 
     147                        if (vChar != 'u' && vChar != 'U') return false; 
     148                        vChar = pValue.charAt(3); 
     149                        if (vChar == 'e' || vChar == 'E') return true; 
     150                } 
     151                return false; 
    148152        } 
    149153 
     
    158162        } 
    159163         
     164        /** 
     165         *  
     166         */ 
     167        public static final Document hCreateDoc(){ 
     168                return new DocumentImpl(false); 
     169        } 
     170 
    160171        public static final Node hGetNodeFromString(IData pData, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    161172                String vMime = pData.getMime(pDialog, pOwner, pArguments); 
    162                 if(vMime == IData.MIME_TEXT_XML) { 
     173                if (vMime == IData.MIME_TEXT_XML) { 
    163174                        String vString = pData.getString(pDialog, pOwner, pArguments); 
    164175                        return hGetDocumentFromString(vString); 
    165                 } else if(vMime == IData.MIME_TEXT_XMLFRAGMENT) { 
     176                } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) { 
    166177                        String vString = pData.getString(pDialog, pOwner, pArguments); 
    167178                        return hGetDocumentFragmentFromString(vString); 
     
    171182        } 
    172183 
    173          
    174184        public static final Node hGetNodeFromString(IComputedData pData) throws Exception { 
    175185                String vMime = pData.getMime(); 
    176                 if(vMime == IData.MIME_TEXT_XML) { 
     186                if (vMime == IData.MIME_TEXT_XML) { 
    177187                        String vString = pData.getString(); 
    178188                        return hGetDocumentFromString(vString); 
    179                 } else if(vMime == IData.MIME_TEXT_XMLFRAGMENT) { 
     189                } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) { 
    180190                        String vString = pData.getString(); 
    181191                        return hGetDocumentFragmentFromString(vString); 
     
    188198                return new TextImpl(null, pData); 
    189199        } 
    190          
     200 
     201        public static final Node hGetNodeFromNodeIterator(NodeIterator pIt, String pMime) throws Exception { 
     202                if (pMime != null && pMime == IData.MIME_TEXT_XMLFRAGMENT) { 
     203                        //TODO 
     204                        //                      DocumentFragment vFrag = null; 
     205                        //                      Node vNode; 
     206                        //              while (null != (vNode = pIt.nextNode())) { 
     207                        //                      vFrag.appendChild(vNode.cloneNode(true)); 
     208                        //              } 
     209                        //                      return vFrag; 
     210                } 
     211                return pIt.nextNode(); 
     212        } 
     213 
    191214        public static final String hGetStringFromNode(IData pData, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    192215                StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); 
     
    200223                return vResult; 
    201224        } 
    202          
     225 
    203226        public static final String hGetStringFromNode(IComputedData pData) throws Exception { 
    204227                StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); 
     
    212235                return vResult; 
    213236        } 
    214          
     237 
    215238        public static final String hGetStringFromNode(Node pData) throws Exception { 
    216                 if(pData == null) return ""; 
     239                if (pData == null) return ""; 
    217240                StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); 
    218241                String vResult = ""; 
     
    225248                return vResult; 
    226249        } 
    227          
     250 
    228251        public static final void hWriteFromNode(IData pData, IHDialog pDialog, Object pOwner, Object pArguments, Writer pWriter) throws Exception { 
    229252                String vMime = pData.getMime(pDialog, pOwner, pArguments); 
    230                 if(vMime == IData.MIME_TEXT_HTML) { 
     253                if (vMime == IData.MIME_TEXT_HTML) { 
    231254                        hWriteFromNode(pData.getNode(pDialog, pOwner, pArguments), Method.HTML, pWriter); 
    232                 } else if(vMime == IData.MIME_TEXT_PLAIN || vMime == IData.MIME_TEXT_JS_FCT || vMime == IData.MIME_TEXT_JS_EXP) { 
     255                } else if (vMime == IData.MIME_TEXT_PLAIN || vMime == IData.MIME_TEXT_JS_FCT || vMime == IData.MIME_TEXT_JS_EXP) { 
    233256                        hWriteFromNode(pData.getNode(pDialog, pOwner, pArguments), Method.Text, pWriter); 
    234257                } else { 
     
    236259                } 
    237260        } 
    238          
     261 
    239262        public static final void hWriteFromNode(IComputedData pData, Writer pWriter) throws Exception { 
    240263                Node vNode = pData.getNode(); 
    241                 if(vNode == null) return; 
     264                if (vNode == null) return; 
    242265                String vMime = pData.getMime(); 
    243                 if(vMime == IData.MIME_TEXT_HTML) { 
     266                if (vMime == IData.MIME_TEXT_HTML) { 
    244267                        hWriteFromNode(vNode, Method.HTML, pWriter); 
    245                 } else if(vMime == IData.MIME_TEXT_PLAIN || vMime == IData.MIME_TEXT_JS_FCT || vMime == IData.MIME_TEXT_JS_EXP) { 
     268                } else if (vMime == IData.MIME_TEXT_PLAIN || vMime == IData.MIME_TEXT_JS_FCT || vMime == IData.MIME_TEXT_JS_EXP) { 
    246269                        hWriteFromNode(vNode, Method.Text, pWriter); 
    247270                } else { 
     
    249272                } 
    250273        } 
    251          
     274 
    252275        /** 
    253276         * Sérialise un node en fonction d'une méthode donnée : xml, text, html. 
     
    259282                vSerializer.asDOMSerializer().serialize(pNode); 
    260283        } 
    261          
    262284 
    263285        public static final DocumentFragment hGetDocumentFragmentFromString(String vString) throws Exception, SAXNotRecognizedException, SAXNotSupportedException, IOException, SAXException { 
    264286                DocumentImpl vDoc = new DocumentImpl(false, vString.length()); 
    265                 DocumentFragmentImpl vFrag = (DocumentFragmentImpl)vDoc.createDocumentFragment(); 
     287                DocumentFragmentImpl vFrag = (DocumentFragmentImpl) vDoc.createDocumentFragment(); 
    266288                XMLReader vReader = HPoolXmlReader.hGet().hGetXmlReader(true, false); 
    267289                try { 
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXPathOnSrcDynamique2.java

    r7458 r7478  
    4242 
    4343import org.w3c.dom.Element; 
     44import org.w3c.dom.Node; 
    4445 
    4546import com.scenari.m.co.agent.IWAgent; 
     
    108109        pWriter.write(getString(pDialog, pOwner, pArguments)); 
    109110    } 
     111     
     112    public final Node getNode(IHDialog pDialog, Object pOwner, Object pArguments) throws java.lang.Exception { 
     113        try { 
     114            XPathContext vPathContext = ((IWAgent)pOwner).hGetInstance().hPopXPathContext(); 
     115            VariableStack vStack = vPathContext.getVarStack(); 
     116            vStack.pushVariable(ZXPath.QNAME_VDIALOG, new XObject(pDialog)); 
     117            vStack.pushVariable(ZXPath.QNAME_VAGENT, new XObject(pOwner)); 
     118                        if(pArguments != null){ 
     119                                vStack.pushVariable(ZXPath.QNAME_VARGUMENTS, new XObject(pArguments)); 
     120                        } 
     121            vStack.markGlobalStackFrame(); 
     122            vPathContext.setPrefixResolver(new PrefixResolverDefault(fSrcRoot)); 
     123            return HDonneeUtils.hGetNodeFromNodeIterator(fXPathCompiled.execute(vPathContext, fSrcRoot).nodeset(), fMime); 
     124        } catch (Exception e) { 
     125            throw (Exception) HLogMgr.hAddMessage(e, "Echec au calcul XPath d'une donnee (xpathOnSrc-dynamique)."); 
     126        } 
     127    } 
    110128 
    111129    /** 
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXsl.java

    r7458 r7478  
    4141import java.io.InputStream; 
    4242import java.io.StringReader; 
    43 import java.io.Writer; 
    44  
     43 
     44import javax.xml.transform.Result; 
    4545import javax.xml.transform.Templates; 
    4646import javax.xml.transform.Transformer; 
     
    4848import javax.xml.transform.dom.DOMSource; 
    4949import javax.xml.transform.sax.SAXSource; 
    50 import javax.xml.transform.stream.StreamResult; 
    5150 
    5251import org.w3c.dom.Node; 
     
    108107                return (fMime == null) ? WDonnee.MIME_TEXT_PLAIN : fMime; 
    109108        } 
    110          
     109 
    111110        /** 
    112111         *  
     
    206205         *  
    207206         */ 
    208         protected final void xGetValue(IHDialog pDialog, IWAgent pAgent, Object pArguments, Writer pWriter) throws Exception { 
     207        protected final void xGetValue(IHDialog pDialog, IWAgent pAgent, Object pArguments, Result pResult) throws Exception { 
    209208 
    210209                if (fTemplate != null) { 
     
    232231                                DOMSource vSource = new DOMSource(pAgent.hGetElementRoot()); 
    233232                                vSource.setSystemId(vResolver.hGetSystemId()); 
    234                                 vTransformer.transform(vSource, new StreamResult(pWriter)); 
     233                                vTransformer.transform(vSource, pResult); 
    235234 
    236235                                if (sTrace.hIsActive()) { 
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslDouble.java

    r7458 r7478  
    4545import javax.xml.transform.Transformer; 
    4646import javax.xml.transform.TransformerFactory; 
     47import javax.xml.transform.dom.DOMResult; 
    4748import javax.xml.transform.dom.DOMSource; 
    4849import javax.xml.transform.sax.SAXSource; 
    4950import javax.xml.transform.stream.StreamResult; 
    5051 
     52import org.w3c.dom.Document; 
    5153import org.w3c.dom.Element; 
     54import org.w3c.dom.Node; 
    5255import org.xml.sax.InputSource; 
    5356import org.xml.sax.XMLReader; 
     
    100103        /** 
    101104         *  
    102          *  
    103          * @see com.scenari.m.co.donnee.IData#getString(com.scenari.m.co.dialog.IHDialog, 
    104          *      java.lang.Object, java.lang.Object) 
    105105         */ 
    106106        public final String getString(IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
     
    108108                String vResult = ""; 
    109109                try { 
    110                         xGetValue(pDialog, (IWAgent) pOwner, pArguments, vWriter); 
     110                        xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(vWriter)); 
    111111                        vResult = vWriter.getBuffer().substring(0); 
    112112                } finally { 
     
    115115                return vResult; 
    116116        } 
    117  
    118         /** 
    119          *  
    120          *  
    121          * @see com.scenari.m.co.donnee.IData#writeValue(java.io.Writer, 
    122          *      com.scenari.m.co.dialog.IHDialog, java.lang.Object, 
    123          *      java.lang.Object) 
     117         
     118    public final Node getNode(IHDialog pDialog, Object pOwner, Object pArguments) throws java.lang.Exception { 
     119        Document vDoc = HDonneeUtils.hCreateDoc(); 
     120        xGetValue(pDialog, (IWAgent) pOwner, pArguments, new DOMResult(vDoc)); 
     121        return vDoc; 
     122    } 
     123 
     124        /** 
     125         *  
    124126         */ 
    125127        public final void writeValue(Writer pWriter, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    126                 xGetValue(pDialog, (IWAgent) pOwner, pArguments, pWriter); 
    127         } 
    128  
    129         /** 
    130          *  
    131          *  
    132          * @see com.scenari.m.co.donnee.IAgentData#wSetComposant(com.scenari.m.co.composant.IWComposant, 
    133          *      org.w3c.dom.Element, IHSource) 
     128                xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(pWriter)); 
     129        } 
     130 
     131        /** 
     132         *  
    134133         */ 
    135134        public final IAgentData wSetComposant(IWComposant pComposant, Element pNodeRoot, IHSource pSource) throws Exception { 
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslDynamique.java

    r7458 r7478  
    4242import java.io.Writer; 
    4343 
     44import javax.xml.transform.dom.DOMResult; 
     45import javax.xml.transform.stream.StreamResult; 
     46 
     47import org.w3c.dom.Document; 
    4448import org.w3c.dom.Element; 
     49import org.w3c.dom.Node; 
    4550 
    4651import com.scenari.m.co.agent.IWAgent; 
     
    5863 
    5964public class WDonneeXslDynamique extends WDonneeXsl implements Cloneable { 
    60          
     65 
    6166        /** 
    6267         *  
     
    6570                super(); 
    6671        } 
    67          
     72 
    6873        /** 
    6974         *  
     
    7479                return IAgentData.LEVEL_DYNAMIQUE; 
    7580        } 
    76          
     81 
    7782        /** 
    7883         *  
     
    8489                String vResult = ""; 
    8590                try { 
    86                         xGetValue(pDialog, (IWAgent)pOwner, pArguments, vWriter); 
     91                        xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(vWriter)); 
    8792                        vResult = vWriter.getBuffer().substring(0); 
    8893                } finally { 
     
    9297        } 
    9398         
     99    public final Node getNode(IHDialog pDialog, Object pOwner, Object pArguments) throws java.lang.Exception { 
     100        Document vDoc = HDonneeUtils.hCreateDoc(); 
     101        xGetValue(pDialog, (IWAgent) pOwner, pArguments, new DOMResult(vDoc)); 
     102        return vDoc; 
     103    } 
     104 
    94105        /** 
    95106         *  
     
    98109         */ 
    99110        public final void writeValue(Writer pWriter, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    100                 xGetValue(pDialog, (IWAgent)pOwner, pArguments, pWriter); 
     111                xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(pWriter)); 
    101112        } 
    102          
     113 
    103114        /** 
    104115         *  
     
    109120                return this; 
    110121        } 
    111          
     122 
    112123        /** 
    113124         *  
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslMonoTemplate.java

    r7458 r7478  
    4545import javax.xml.transform.Transformer; 
    4646import javax.xml.transform.TransformerFactory; 
     47import javax.xml.transform.dom.DOMResult; 
    4748import javax.xml.transform.dom.DOMSource; 
    4849import javax.xml.transform.sax.SAXSource; 
    4950import javax.xml.transform.stream.StreamResult; 
    5051 
     52import org.w3c.dom.Document; 
    5153import org.w3c.dom.Element; 
     54import org.w3c.dom.Node; 
    5255import org.xml.sax.InputSource; 
    5356import org.xml.sax.XMLReader; 
     
    106109         */ 
    107110        public final String getString(IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    108                 StringWriter vWriter = com.scenari.s.fw.utils.HPoolBuffer.get().hGetStringWriter(); 
    109                 xGetValue(pDialog, (IWAgent) pOwner, pArguments, vWriter); 
     111                StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); 
     112                xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(vWriter)); 
    110113                String vResult = vWriter.getBuffer().substring(0); 
    111                 com.scenari.s.fw.utils.HPoolBuffer.get().hFreeStringWriter(vWriter); 
    112  
     114                HPoolBuffer.get().hFreeStringWriter(vWriter); 
    113115                return vResult; 
    114116        } 
     117         
     118    public final Node getNode(IHDialog pDialog, Object pOwner, Object pArguments) throws java.lang.Exception { 
     119        Document vDoc = HDonneeUtils.hCreateDoc(); 
     120        xGetValue(pDialog, (IWAgent) pOwner, pArguments, new DOMResult(vDoc)); 
     121        return vDoc; 
     122    } 
    115123 
    116124        /** 
     
    122130         */ 
    123131        public final void writeValue(Writer pWriter, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
    124                 xGetValue(pDialog, (IWAgent) pOwner, pArguments, pWriter); 
     132                xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(pWriter)); 
    125133        } 
    126134 
  • trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslOnSrcDynamique2.java

    r7458 r7478  
    4242import java.io.Writer; 
    4343 
     44import javax.xml.transform.Result; 
    4445import javax.xml.transform.Transformer; 
     46import javax.xml.transform.TransformerConfigurationException; 
     47import javax.xml.transform.TransformerException; 
     48import javax.xml.transform.dom.DOMResult; 
    4549import javax.xml.transform.dom.DOMSource; 
    4650import javax.xml.transform.stream.StreamResult; 
    4751 
     52import org.w3c.dom.Document; 
    4853import org.w3c.dom.Element; 
     54import org.w3c.dom.Node; 
    4955 
    5056import com.scenari.m.co.agent.IWAgent; 
     
    101107     */ 
    102108    public final void writeValue(Writer pWriter, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 
     109        Result vResult = new StreamResult(pWriter); 
     110        xExecuteXsl(vResult, pDialog, pOwner, pArguments); 
     111    } 
     112     
     113    public final Node getNode(IHDialog pDialog, Object pOwner, Object pArguments) throws java.lang.Exception { 
     114        Document vDoc = HDonneeUtils.hCreateDoc(); 
     115        xExecuteXsl(new DOMResult(vDoc), pDialog, pOwner, pArguments); 
     116        return vDoc; 
     117    } 
    103118 
    104         //On execute la XSL 
     119        protected void xExecuteXsl(Result pResult, IHDialog pDialog, Object pOwner, Object pArguments) throws TransformerConfigurationException, Exception, TransformerException { 
     120                //On execute la XSL 
    105121        IWAgent vAgent = (IWAgent) pOwner; 
    106122        IWComposant vComposant = vAgent.hGetComposant(); 
     
    119135        DOMSource vSource = new DOMSource(fSrcRoot); 
    120136        vSource.setSystemId(vResolver.hGetSystemId()); 
    121         vTransformer.transform(vSource, new StreamResult(pWriter)); 
    122  
    123     } 
     137        vTransformer.transform(vSource, pResult); 
     138        } 
    124139 
    125140    /** 
Note: See TracChangeset for help on using the changeset viewer.