SPFE Documentation | Collections > SPFE Function Reference > get-sources

Function: get-sources

get-sources(file-list as item()*, load-message as item()*) as item()*

Description

The get-sources is used to load a set of XML source files into a variable. It takes a string value that contains a set of file paths separated by semicolons. The function will fix directory separators characters in the file paths. You should use the get-sources function to load source files, irrespective of whether you are loading one file or several. This makes your script resilient if the number of source files should change, and also allows for more flexibility in downstream processes, allowing them to produce one file or many.

Return value

Return type: item()*

Returns a sequence of XML documents named in the file list.

Source file

$SPFEOT_HOME/1.0/scripts/common/utility-functions.xsl

Parameters

file-list

Type: item()*

A string containing a list of XML file paths separated by semi-colons.

load-message

Type: item()*

A string containing an optional message to be displayed by the script when loading a file. If specified, the message will be prepended to the name of each file as it is loaded, and displayed by a call to the info function.

Definition

            <xsl:function name="sf:get-sources">
		               <xsl:param name="file-list"/>
		               <xsl:sequence select="sf:get-sources($file-list, '')"/>
	           </xsl:function>
         
            <xsl:function name="sf:get-sources">
		               <xsl:param name="file-list"/>
		               <xsl:param name="load-message"/>
		             
		  <xsl:for-each select="tokenize(translate($file-list, '\', '/'), ';')">
			                   <xsl:variable name="one-file" select="sf:local-to-url(.)"/>
			                   <xsl:if test="normalize-space($load-message)">
				                       <xsl:call-template name="sf:info">
					                           <xsl:with-param name="message" select="$load-message, $one-file "/>
				                       </xsl:call-template>
			                   </xsl:if>
			                   <xsl:if test="not(doc-available($one-file))">
				                       <xsl:call-template name="sf:error">
					                           <xsl:with-param name="message">File not found:           <xsl:value-of select="$one-file"/>
                        </xsl:with-param>
				                       </xsl:call-template>
			                   </xsl:if>
			                   <xsl:sequence select="document($one-file)"/>
		               </xsl:for-each>
	           </xsl:function>