<?xml version="1.0" encoding="UTF-8"?>
<structure version="14" html-doctype="HTML4 Transitional" compatibility-view="IE9" relativeto="*SPS" encodinghtml="UTF-8" encodingrtf="ISO-8859-1" encodingpdf="UTF-8" useimportschema="1" embed-images="1" enable-authentic-scripts="1" authentic-scripts-in-debug-mode-external="0" generated-file-location="DEFAULT">
	<parameters/>
	<schemasources>
		<namespaces/>
		<schemasources>
			<xsdschemasource name="XML" main="1" schemafile="Data.xsd" workingxmlfile="Data.xml"/>
		</schemasources>
	</schemasources>
	<modules/>
	<flags>
		<scripts/>
		<globalparts/>
		<designfragments/>
		<pagelayouts/>
		<xpath-functions/>
	</flags>
	<scripts>
		<script language="javascript"/>
	</scripts>
	<script-project>
		<Project version="2" app="AuthenticView"/>
	</script-project>
	<importedxslt/>
	<globalstyles>
		<rule url="Samples.css">
			<media>
				<media value="all"/>
			</media>
		</rule>
	</globalstyles>
	<mainparts>
		<children>
			<globaltemplate subtype="main" match="/">
				<document-properties/>
				<children>
					<documentsection>
						<properties columncount="1" columngap="0.50in" headerfooterheight="fixed" pagemultiplepages="0" pagenumberingformat="1" pagenumberingstartat="auto" pagestart="next" paperheight="11in" papermarginbottom="0.79in" papermarginfooter="0.30in" papermarginheader="0.30in" papermarginleft="0.60in" papermarginright="0.60in" papermargintop="0.79in" paperwidth="8.50in"/>
					</documentsection>
					<paragraph paragraphtag="p">
						<properties class="info"/>
						<children>
							<text fixtext="This example demonstrates how to define your own XPath functions and use them in different design elements."/>
						</children>
					</paragraph>
					<template subtype="source" match="XML">
						<children>
							<template subtype="element" match="data">
								<children>
									<paragraph paragraphtag="p">
										<properties class="explanation"/>
										<children>
											<text fixtext="The underlying XML file defines numbers in their written form: One, Two, Three, Four."/>
										</children>
									</paragraph>
									<paragraph paragraphtag="p">
										<properties class="explanation"/>
										<children>
											<text fixtext="Use Authentic to select one of the allowed values in this combo-box: "/>
										</children>
									</paragraph>
									<paragraph>
										<styles margin-left="30px"/>
										<children>
											<template subtype="element" match="strings">
												<children>
													<template subtype="attribute" match="selected">
														<children>
															<condition>
																<children>
																	<conditionbranch xpath="$SV_OutputFormat=&apos;Authentic&apos;">
																		<children>
																			<combobox enumeration="1">
																				<styles width="1.46in"/>
																				<children>
																					<content/>
																				</children>
																				<selectoption description="Four" value="Four"/>
																				<selectoption description="One" value="One"/>
																				<selectoption description="Three" value="Three"/>
																				<selectoption description="Two" value="Two"/>
																			</combobox>
																		</children>
																	</conditionbranch>
																	<conditionbranch>
																		<children>
																			<content/>
																		</children>
																	</conditionbranch>
																</children>
															</condition>
														</children>
														<variables/>
													</template>
												</children>
												<variables/>
											</template>
										</children>
									</paragraph>
									<paragraph paragraphtag="p">
										<properties class="explanation"/>
										<children>
											<text fixtext="In this form values cannot be processed easily. Therefore a function TranslateToInteger was defined, which takes text as parameter and returns a corresponding integer value (see XPath Functions under Schema Tree or Design Tree for a list of all functions)."/>
										</children>
									</paragraph>
									<paragraph>
										<styles margin-left="30px"/>
										<children>
											<text fixtext="TranslateToInteger( &apos;"/>
											<template subtype="element" match="strings">
												<children>
													<template subtype="attribute" match="selected">
														<editorproperties editable="0"/>
														<children>
															<content/>
														</children>
														<variables/>
													</template>
												</children>
												<variables/>
											</template>
											<text fixtext="&apos; ) = "/>
											<autocalc xpath="sps:TranslateToInteger(strings/@selected)"/>
										</children>
									</paragraph>
									<paragraph paragraphtag="p">
										<properties class="explanation"/>
										<children>
											<text fixtext="With this integer value we can now perform any further processing easily. For example, we can create a new text by repeating some other string multiple times. Change the text below in Authentic to see the result:"/>
										</children>
									</paragraph>
									<paragraph>
										<styles margin-left="30px"/>
										<children>
											<template subtype="attribute" match="sample-string">
												<children>
													<condition>
														<children>
															<conditionbranch xpath="$SV_OutputFormat=&apos;Authentic&apos;">
																<children>
																	<editfield>
																		<children>
																			<content/>
																		</children>
																	</editfield>
																</children>
															</conditionbranch>
															<conditionbranch>
																<children>
																	<content/>
																</children>
															</conditionbranch>
														</children>
													</condition>
												</children>
												<variables/>
											</template>
										</children>
									</paragraph>
									<paragraph paragraphtag="p">
										<properties class="explanation"/>
										<children>
											<text fixtext="The repeated text is a result of another function which was designed here. It takes two parameters: text and how many times to repeat. There are multiple possibilities to implement such function - in this particular sample it calls itself multiple times and is therefore named a recursive function."/>
										</children>
									</paragraph>
									<paragraph>
										<styles margin-left="30px"/>
										<children>
											<text fixtext="RepeatText( &apos;"/>
											<template subtype="attribute" match="sample-string">
												<children>
													<content/>
												</children>
												<variables/>
											</template>
											<text fixtext="&apos;, "/>
											<autocalc xpath="sps:TranslateToInteger(strings/@selected)"/>
											<text fixtext=" ) = &apos;"/>
											<autocalc xpath="sps:RepeatText( @sample-string, sps:TranslateToInteger(strings/@selected) )"/>
											<text fixtext="&apos;"/>
										</children>
									</paragraph>
								</children>
								<variables/>
							</template>
						</children>
						<variables/>
					</template>
				</children>
			</globaltemplate>
		</children>
	</mainparts>
	<globalparts/>
	<designfragments/>
	<xmltables/>
	<authentic-custom-toolbar-buttons/>
	<xpath-functions>
		<xpath-function name="TranslateToInteger" value="if ( $FromString = &apos;One&apos; ) then 1
else if ( $FromString = &apos;Two&apos; ) then 2
else if ( $FromString = &apos;Three&apos; ) then 3
else if ( $FromString = &apos;Four&apos; ) then 4
else 0"/>
		<xpath-function-name>
			<variable name="FromString" valuetype="xs:string"/>
		</xpath-function-name>
	</xpath-functions>
	<xpath-functions>
		<xpath-function name="RepeatText" value="if ( $RepeatCount &gt; 1 )
then concat( $TextToRepeat, sps:RepeatText( $TextToRepeat, $RepeatCount -1 ) )
else $TextToRepeat"/>
		<xpath-function-name>
			<variable name="TextToRepeat" valuetype="xs:string"/>
			<variable name="RepeatCount" valuetype="xs:integer"/>
		</xpath-function-name>
	</xpath-functions>
</structure>
