Limit XSLT/XPATH Processor

Here should go questions about transforming XML with XSLT and FOP.
nyraruiz
Posts: 3
Joined: Wed Jul 13, 2022 4:45 pm

Limit XSLT/XPATH Processor

Post by nyraruiz »

Hi,
I am making a data feed for a vendor. I am transforming the data to meet their format using XSLT. I developed a transformation, and within it it had

Code: Select all

select="string-join((for $i in (l to $length) return '0'))"
This works ok in the oxygen xml debug, but when i attempted to do the transformation with vendor it broke. They explained to me that this function uses xpath 3.0, and that they process their xpath on 2.0 which causes it to fail.

My question is, how can i limit the version of xpath that oxygen uses for its intelli-sense and execution? I found a thread that said to go to
Options -> Preferences -> XML -> XSLT-XQuery -> XSLT and then change the validation engine, but I dont understand what all this means. I'm super new to XSLT stuff; I normally live in C# land x_x

My full function

Code: Select all

<xsl:function name="this:pad" as="xsd:string">
		<xsl:param name="direction" as="xsd:string"/>
		<xsl:param name="length" as="xsd:integer"/>
		<xsl:param name="padChar" as="xsd:string"/>
		<xsl:param name="value"/>
		<xsl:variable name="padding" select="
				string-join((for $i in (1 to $length)
				return
					$padChar))"/>
		<xsl:choose>
			<xsl:when test="string-length($value) = $length">
				<xsl:sequence select="$value"/>
			</xsl:when>
			<xsl:when test="string-length($value) > $length">
				<xsl:choose>
					<xsl:when test="$direction = $Direction_Left">
						<xsl:sequence select="substring($value, 1, $length)"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:sequence
							select="substring($value, string-length($value) - $length + 1, $length)"
						/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="$direction = $Direction_Left">
				<xsl:sequence
					select="concat(substring($padding, string-length($padding) - ($length - string-length($value)) + 1), $value)"
				/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:sequence
					select="concat($value, substring($padding, string-length($padding) - ($length - string-length($value)) + 1))"
				/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
nyraruiz
Posts: 3
Joined: Wed Jul 13, 2022 4:45 pm

Re: Limit XSLT/XPATH Processor

Post by nyraruiz »

Can this be approved? I edited the question bc of typos and then it re-flagged it as needing authorization. I think it is stuck now
tavy
Posts: 364
Joined: Thu Jul 01, 2004 12:29 pm

Re: Limit XSLT/XPATH Processor

Post by tavy »

Hello,

Oxygen automatically detects from the document the XSLT version to be used for content completion and validation.
If you use Oxygen XML Editor 24.1, the default validation engine for XSLT 2.0 is Saxon 10.6, that is an XSLT 3.0 processor. This means that it will validate XSLT 2.0 stylesheets even if they contain XSLT 3.0 functions. You can read more about backward compatibility in the XSLT specification:
https://www.w3.org/TR/xslt-30/#backwards

If you want to make sure that your XSLT 2.0 stylesheet does not contain XSLT 3.0 functions, you can try to install an older version of Saxon. I recommend you to install Saxon 9.6 addon. You can do this from Help > Install new add-ons. Find more details in our user manual:
https://www.oxygenxml.com/doc/versions/ ... addon.html

Then you can go to Options -> Preferences -> XML -> XSLT-XQuery -> XSLT options page, and select Saxon 9.6 as an XSLT 2.0 validation engine.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
nyraruiz
Posts: 3
Joined: Wed Jul 13, 2022 4:45 pm

Re: Limit XSLT/XPATH Processor

Post by nyraruiz »

thank you!!
Post Reply