Changeset 7478
- Timestamp:
- 11/23/06 22:24:42 (5 years ago)
- Location:
- trunk/Jav_CO/com/scenari/m/co/donnee
- Files:
-
- 2 added
- 8 edited
-
HADonneeMgr.java (modified) (2 diffs)
-
HDonneeUtils.java (modified) (15 diffs)
-
WDonneeNodeFix.java (added)
-
WDonneeXPathOnSrcDynamique2.java (modified) (2 diffs)
-
WDonneeXsl.java (modified) (5 diffs)
-
WDonneeXslDouble.java (modified) (4 diffs)
-
WDonneeXslDynamique.java (modified) (8 diffs)
-
WDonneeXslMonoTemplate.java (modified) (3 diffs)
-
WDonneeXslOnSrcDynamique2.java (modified) (3 diffs)
-
XSaxHandlerToDom.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_CO/com/scenari/m/co/donnee/HADonneeMgr.java
r7458 r7478 49 49 import com.scenari.s.fw.log.HLogMgr; 50 50 51 52 51 /** 53 52 * … … 56 55 57 56 public static final String TYPE_FIXE = "fixe"; 57 58 58 public static final String TYPE_FIXE_ALIAS = "fixe-alias"; 59 59 60 public static final String TYPE_FIXE_SYSTEM_PROPS = "fixe-systemProperties"; 61 62 public static final String TYPE_FIXE_NODE = "fixe-node"; 63 60 64 public static final String TYPE_XPATH_STATIQUE = "xpath-statique"; 65 61 66 public static final String TYPE_XPATH_DYNAMIQUE = "xpath-dynamique"; 67 62 68 public static final String TYPE_XPATH_DOUBLE = "xpath-double"; 69 63 70 public static final String TYPE_XPATHONSRC_DYNAMIQUE = "xpathOnSrc-dynamique"; 71 64 72 public static final String TYPE_EXTRAIT_XML_STATIQUE = "extraitxml-statique"; 73 65 74 public static final String TYPE_XSL_STATIQUE = "xsl-statique"; 75 66 76 public static final String TYPE_XSL_DYNAMIQUE = "xsl-dynamique"; 77 67 78 public static final String TYPE_XSL_DOUBLE = "xsl-double"; 79 68 80 public static final String TYPE_XSL_MONOTEMPLATE = "xsl-monotemplate"; 81 69 82 public static final String TYPE_XSL_XPATH = "xsl-xpath"; 83 70 84 public static final String TYPE_XSL_BEANSHELL = "xsl-beanshell"; 85 71 86 public static final String TYPE_XSL_WEBMACRO = "xsl-webmacro"; 87 72 88 public static final String TYPE_XSLONSRC_DYNAMIQUE = "xslOnSrc-dynamique"; 89 73 90 public static final String TYPE_COMPOSITION_DYNAMIQUE = "composition-dynamique"; 91 74 92 public static final String TYPE_CONTEXTUEL_DYNAMIQUE = "contextuel-dynamique"; 93 75 94 public static final String TYPE_WEBMACRO_DYNAMIQUE = "webmacro-dynamique"; 95 76 96 public static final String TYPE_RESULTAT_DYNAMIQUE = "resultat-dynamique"; 97 77 98 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 80 102 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 } 86 247 } 87 /**88 * Permet d'ajouter des type de données ne faisant pas partie du coeur de Scenari.89 *90 * @param pType java.lang.String91 * @param pClass java.lang.Class92 */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érieurement99 * par les méthodes IWADonnee.hSetValue(String) ou IWADonnee.hSetValueParRef(String)100 *101 * @return com.scenari.m.co.donnee.IWADonnee102 * @param pType Type de donnée.103 * @param pMimeType Mime-type de donnée produite.104 * @param pCompType com.scenari.m.co.composant.IHComposantType105 */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ée114 * est déclarée.115 *116 * @return com.scenari.m.co.donnee.IWADonnee117 * @param pType Type de donnée.118 * @param pMimeType Mime-type de donnée produite.119 * @param pCompType com.scenari.m.co.composant.IHComposantType120 * @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 la133 * ressource pDocSource.134 *135 * @return com.scenari.m.co.donnee.IWADonnee136 * @param pType Type de donnée.137 * @param pMimeType Mime-type de donnée produite.138 * @param pCompType com.scenari.m.co.composant.IHComposantType139 * @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érieurement151 * 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 48 48 import org.w3c.dom.DocumentFragment; 49 49 import org.w3c.dom.Node; 50 import org.w3c.dom.traversal.NodeIterator; 50 51 import org.xml.sax.InputSource; 51 52 import org.xml.sax.SAXException; … … 70 71 */ 71 72 public class HDonneeUtils { 72 73 73 74 protected static final Properties OUTPUTPROPS_XML = new Properties(OutputProperties.getDefaultMethodProperties(Method.XML)); 75 74 76 protected static final Properties OUTPUTPROPS_HTML = new Properties(OutputProperties.getDefaultMethodProperties(Method.HTML)); 77 75 78 protected static final Properties OUTPUTPROPS_TEXT = new Properties(OutputProperties.getDefaultMethodProperties(Method.Text)); 76 79 static { 77 80 OUTPUTPROPS_XML.setProperty("omit-xml-declaration", "yes"); 78 81 } 82 79 83 protected static Properties getDefaultMethodProperties(String method) { 80 84 if (method.equals(Method.XML)) { … … 88 92 } 89 93 } 90 94 91 95 /** 92 96 * … … 95 99 super(); 96 100 } 97 101 98 102 /** 99 103 * Transforme une valeur string en boolean en recherchant une représentation … … 104 108 */ 105 109 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 } 122 126 return true; 123 127 } 124 128 125 129 /** 126 130 * Transforme une valeur string en boolean en recherchant une représentation … … 131 135 */ 132 136 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; 148 152 } 149 153 … … 158 162 } 159 163 164 /** 165 * 166 */ 167 public static final Document hCreateDoc(){ 168 return new DocumentImpl(false); 169 } 170 160 171 public static final Node hGetNodeFromString(IData pData, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 161 172 String vMime = pData.getMime(pDialog, pOwner, pArguments); 162 if (vMime == IData.MIME_TEXT_XML) {173 if (vMime == IData.MIME_TEXT_XML) { 163 174 String vString = pData.getString(pDialog, pOwner, pArguments); 164 175 return hGetDocumentFromString(vString); 165 } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) {176 } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) { 166 177 String vString = pData.getString(pDialog, pOwner, pArguments); 167 178 return hGetDocumentFragmentFromString(vString); … … 171 182 } 172 183 173 174 184 public static final Node hGetNodeFromString(IComputedData pData) throws Exception { 175 185 String vMime = pData.getMime(); 176 if (vMime == IData.MIME_TEXT_XML) {186 if (vMime == IData.MIME_TEXT_XML) { 177 187 String vString = pData.getString(); 178 188 return hGetDocumentFromString(vString); 179 } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) {189 } else if (vMime == IData.MIME_TEXT_XMLFRAGMENT) { 180 190 String vString = pData.getString(); 181 191 return hGetDocumentFragmentFromString(vString); … … 188 198 return new TextImpl(null, pData); 189 199 } 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 191 214 public static final String hGetStringFromNode(IData pData, IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { 192 215 StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); … … 200 223 return vResult; 201 224 } 202 225 203 226 public static final String hGetStringFromNode(IComputedData pData) throws Exception { 204 227 StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); … … 212 235 return vResult; 213 236 } 214 237 215 238 public static final String hGetStringFromNode(Node pData) throws Exception { 216 if (pData == null) return "";239 if (pData == null) return ""; 217 240 StringWriter vWriter = HPoolBuffer.get().hGetStringWriter(); 218 241 String vResult = ""; … … 225 248 return vResult; 226 249 } 227 250 228 251 public static final void hWriteFromNode(IData pData, IHDialog pDialog, Object pOwner, Object pArguments, Writer pWriter) throws Exception { 229 252 String vMime = pData.getMime(pDialog, pOwner, pArguments); 230 if (vMime == IData.MIME_TEXT_HTML) {253 if (vMime == IData.MIME_TEXT_HTML) { 231 254 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) { 233 256 hWriteFromNode(pData.getNode(pDialog, pOwner, pArguments), Method.Text, pWriter); 234 257 } else { … … 236 259 } 237 260 } 238 261 239 262 public static final void hWriteFromNode(IComputedData pData, Writer pWriter) throws Exception { 240 263 Node vNode = pData.getNode(); 241 if (vNode == null) return;264 if (vNode == null) return; 242 265 String vMime = pData.getMime(); 243 if (vMime == IData.MIME_TEXT_HTML) {266 if (vMime == IData.MIME_TEXT_HTML) { 244 267 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) { 246 269 hWriteFromNode(vNode, Method.Text, pWriter); 247 270 } else { … … 249 272 } 250 273 } 251 274 252 275 /** 253 276 * Sérialise un node en fonction d'une méthode donnée : xml, text, html. … … 259 282 vSerializer.asDOMSerializer().serialize(pNode); 260 283 } 261 262 284 263 285 public static final DocumentFragment hGetDocumentFragmentFromString(String vString) throws Exception, SAXNotRecognizedException, SAXNotSupportedException, IOException, SAXException { 264 286 DocumentImpl vDoc = new DocumentImpl(false, vString.length()); 265 DocumentFragmentImpl vFrag = (DocumentFragmentImpl) vDoc.createDocumentFragment();287 DocumentFragmentImpl vFrag = (DocumentFragmentImpl) vDoc.createDocumentFragment(); 266 288 XMLReader vReader = HPoolXmlReader.hGet().hGetXmlReader(true, false); 267 289 try { -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXPathOnSrcDynamique2.java
r7458 r7478 42 42 43 43 import org.w3c.dom.Element; 44 import org.w3c.dom.Node; 44 45 45 46 import com.scenari.m.co.agent.IWAgent; … … 108 109 pWriter.write(getString(pDialog, pOwner, pArguments)); 109 110 } 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 } 110 128 111 129 /** -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXsl.java
r7458 r7478 41 41 import java.io.InputStream; 42 42 import java.io.StringReader; 43 import java.io.Writer; 44 43 44 import javax.xml.transform.Result; 45 45 import javax.xml.transform.Templates; 46 46 import javax.xml.transform.Transformer; … … 48 48 import javax.xml.transform.dom.DOMSource; 49 49 import javax.xml.transform.sax.SAXSource; 50 import javax.xml.transform.stream.StreamResult;51 50 52 51 import org.w3c.dom.Node; … … 108 107 return (fMime == null) ? WDonnee.MIME_TEXT_PLAIN : fMime; 109 108 } 110 109 111 110 /** 112 111 * … … 206 205 * 207 206 */ 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 { 209 208 210 209 if (fTemplate != null) { … … 232 231 DOMSource vSource = new DOMSource(pAgent.hGetElementRoot()); 233 232 vSource.setSystemId(vResolver.hGetSystemId()); 234 vTransformer.transform(vSource, new StreamResult(pWriter));233 vTransformer.transform(vSource, pResult); 235 234 236 235 if (sTrace.hIsActive()) { -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslDouble.java
r7458 r7478 45 45 import javax.xml.transform.Transformer; 46 46 import javax.xml.transform.TransformerFactory; 47 import javax.xml.transform.dom.DOMResult; 47 48 import javax.xml.transform.dom.DOMSource; 48 49 import javax.xml.transform.sax.SAXSource; 49 50 import javax.xml.transform.stream.StreamResult; 50 51 52 import org.w3c.dom.Document; 51 53 import org.w3c.dom.Element; 54 import org.w3c.dom.Node; 52 55 import org.xml.sax.InputSource; 53 56 import org.xml.sax.XMLReader; … … 100 103 /** 101 104 * 102 *103 * @see com.scenari.m.co.donnee.IData#getString(com.scenari.m.co.dialog.IHDialog,104 * java.lang.Object, java.lang.Object)105 105 */ 106 106 public final String getString(IHDialog pDialog, Object pOwner, Object pArguments) throws Exception { … … 108 108 String vResult = ""; 109 109 try { 110 xGetValue(pDialog, (IWAgent) pOwner, pArguments, vWriter);110 xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(vWriter)); 111 111 vResult = vWriter.getBuffer().substring(0); 112 112 } finally { … … 115 115 return vResult; 116 116 } 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 * 124 126 */ 125 127 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 * 134 133 */ 135 134 public final IAgentData wSetComposant(IWComposant pComposant, Element pNodeRoot, IHSource pSource) throws Exception { -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslDynamique.java
r7458 r7478 42 42 import java.io.Writer; 43 43 44 import javax.xml.transform.dom.DOMResult; 45 import javax.xml.transform.stream.StreamResult; 46 47 import org.w3c.dom.Document; 44 48 import org.w3c.dom.Element; 49 import org.w3c.dom.Node; 45 50 46 51 import com.scenari.m.co.agent.IWAgent; … … 58 63 59 64 public class WDonneeXslDynamique extends WDonneeXsl implements Cloneable { 60 65 61 66 /** 62 67 * … … 65 70 super(); 66 71 } 67 72 68 73 /** 69 74 * … … 74 79 return IAgentData.LEVEL_DYNAMIQUE; 75 80 } 76 81 77 82 /** 78 83 * … … 84 89 String vResult = ""; 85 90 try { 86 xGetValue(pDialog, (IWAgent) pOwner, pArguments, vWriter);91 xGetValue(pDialog, (IWAgent) pOwner, pArguments, new StreamResult(vWriter)); 87 92 vResult = vWriter.getBuffer().substring(0); 88 93 } finally { … … 92 97 } 93 98 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 94 105 /** 95 106 * … … 98 109 */ 99 110 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)); 101 112 } 102 113 103 114 /** 104 115 * … … 109 120 return this; 110 121 } 111 122 112 123 /** 113 124 * -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslMonoTemplate.java
r7458 r7478 45 45 import javax.xml.transform.Transformer; 46 46 import javax.xml.transform.TransformerFactory; 47 import javax.xml.transform.dom.DOMResult; 47 48 import javax.xml.transform.dom.DOMSource; 48 49 import javax.xml.transform.sax.SAXSource; 49 50 import javax.xml.transform.stream.StreamResult; 50 51 52 import org.w3c.dom.Document; 51 53 import org.w3c.dom.Element; 54 import org.w3c.dom.Node; 52 55 import org.xml.sax.InputSource; 53 56 import org.xml.sax.XMLReader; … … 106 109 */ 107 110 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)); 110 113 String vResult = vWriter.getBuffer().substring(0); 111 com.scenari.s.fw.utils.HPoolBuffer.get().hFreeStringWriter(vWriter); 112 114 HPoolBuffer.get().hFreeStringWriter(vWriter); 113 115 return vResult; 114 116 } 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 } 115 123 116 124 /** … … 122 130 */ 123 131 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)); 125 133 } 126 134 -
trunk/Jav_CO/com/scenari/m/co/donnee/WDonneeXslOnSrcDynamique2.java
r7458 r7478 42 42 import java.io.Writer; 43 43 44 import javax.xml.transform.Result; 44 45 import javax.xml.transform.Transformer; 46 import javax.xml.transform.TransformerConfigurationException; 47 import javax.xml.transform.TransformerException; 48 import javax.xml.transform.dom.DOMResult; 45 49 import javax.xml.transform.dom.DOMSource; 46 50 import javax.xml.transform.stream.StreamResult; 47 51 52 import org.w3c.dom.Document; 48 53 import org.w3c.dom.Element; 54 import org.w3c.dom.Node; 49 55 50 56 import com.scenari.m.co.agent.IWAgent; … … 101 107 */ 102 108 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 } 103 118 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 105 121 IWAgent vAgent = (IWAgent) pOwner; 106 122 IWComposant vComposant = vAgent.hGetComposant(); … … 119 135 DOMSource vSource = new DOMSource(fSrcRoot); 120 136 vSource.setSystemId(vResolver.hGetSystemId()); 121 vTransformer.transform(vSource, new StreamResult(pWriter)); 122 123 } 137 vTransformer.transform(vSource, pResult); 138 } 124 139 125 140 /**
Note: See TracChangeset
for help on using the changeset viewer.