Saxonica Saxon

Post Reply
jterrano
Newbie
Posts: 6
Joined: Thu Nov 04, 2021 8:00 pm

Saxonica Saxon

Post by jterrano »

We are attempting to remove an parent element that contains a child element of prodTypeCode='FFS'

When using Saxonica Saxon script, I have the script styled as followed :

Code: Select all

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <!-- identity transform -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="*[item/prodTypeCode='FFS']" />
</xsl:stylesheet>
But it will not remove the node that is tagged with FFS.
What am I doing wrong?

I will respond to this message with the code that I am applying this against...
Last edited by jterrano on Wed Dec 01, 2021 2:44 am, edited 2 times in total.
jterrano
Newbie
Posts: 6
Joined: Thu Nov 04, 2021 8:00 pm

Re: Saxonica Saxon

Post by jterrano »

Code: Select all

<?xml version="1.0" ?>
<orders>
	<order>
		<items>
			<item>
				<prodTypeCode>
					MOD
				</prodTypeCode>
			</item>
			<item>
				<prodTypeCode>
					FFS
				</prodTypeCode>
			</item>
			<item>
				<prodTypeCode>
					MOD
				</prodTypeCode>
			</item>
		</items>
	</order>
</orders>
(ive removed all unnecessary nodes...
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Saxonica Saxon

Post by freddyp »

I have not tried getting the XSLT right, but based on the XML structure the XPath you use to select the item node with the value FFS cannot work.

Code: Select all

//item[prodTypeCode='FFS']
does not select anything because of the extra line and the spaces that are part of the string. This XPath does select it:

Code: Select all

//item[contains(prodTypeCode,'FFS')]
jterrano
Newbie
Posts: 6
Joined: Thu Nov 04, 2021 8:00 pm

Re: Saxonica Saxon

Post by jterrano »

So I saw what you meant about the tabs and we successfully processed this xml through saxonica saxon without using contains() but only if we MANUALLY remove the tabs... Do you happen to know of any saxonica saxon PE scripts that can be used to remove the tabs from the XML?
prodTypeCode - tabs.png
prodTypeCode - tabs.png (3.97 KiB) Viewed 2374 times
We would need to remove the tab BEFORE and AFTER (on the next line) that is associated with the prodType.
But if we have to apply it to everything, then so be it.
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Saxonica Saxon

Post by freddyp »

If the value is 'FFS' and only 'FFS' then the only correct way of putting it into an XML is

Code: Select all

<prodTypeCode>FFS</prodTypeCode>
Ergo, you should be looking that the code that creates the XML. Is that under your control? If not, then this app can come to the rescue: https://www.enfocus.com/en/appstore/pro ... ng-replace
Post Reply