xslt - How to read a .properties file inside a .xsl file? -


i have xsl file uses a static website link shown below:

<xsl:template match="my_match">      <xsl:variable name="variable1">         <xsl:value-of select="sel1/label = 'variable1'"/>     </xsl:variable>     <xsl:copy-of select="sites:testpath('http://testsite.com/services/testservice/v1.0', $fname, $lname,      $email , $zip, $phone, $comments, $jps, boolean($myvar), string(cust/@custid), string(@paid))"/> </xsl:template> 

my question how read properties file(key value pair) in xsl file. in properties file (e.g. site.properties) have key called site i.e. site=testsite.com/services/testservice/v1.0

i want use site key in place of specifying url value in xsl i.e. http://testsite.com/services/testservice/v1.0. reason doing this link changes depending on various environments.

is possible? please give suggestions or sample code if possible...also if not possible...is there work-around?

as proof of concept:

input .properties file:

# reading ".properties" entry. ! exclamation mark can mark text comments. website = http://example.com language = english key\ with\ spaces = value looked key "key spaces". 

stylesheet:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"   xmlns:xs="http://www.w3.org/2001/xmlschema"   xmlns:f="functions"   version="2.0">    <xsl:variable name="properties" select="unparsed-text('.properties')" as="xs:string"/>    <xsl:template match="/" name="main">     <xsl:value-of select="f:getproperty('language')"/>   </xsl:template>    <xsl:function name="f:getproperty" as="xs:string?">     <xsl:param name="key" as="xs:string"/>     <xsl:variable name="lines" as="xs:string*" select="       $x in          $i in tokenize($properties, '\n')[matches(., '^[^!#]')] return           tokenize($i, '=')         return translate(normalize-space($x), '\', '')"/>     <xsl:sequence select="$lines[index-of($lines, $key)+1]"/>   </xsl:function>  </xsl:stylesheet> 

the f:getproperty('language') return 'english'.

see proof of concept, needs improved in many ways since not handle many of different ways .properties file can authored.

i belive alejandro or dimitrie improve many times.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -