Page 1 of 1

Saxonica Saxon

Posted: Tue Nov 30, 2021 7:52 pm
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...

Re: Saxonica Saxon

Posted: Tue Nov 30, 2021 7:56 pm
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...

Re: Saxonica Saxon

Posted: Wed Dec 01, 2021 8:27 am
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')]

Re: Saxonica Saxon

Posted: Wed Dec 01, 2021 11:05 pm
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 2864 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.

Re: Saxonica Saxon

Posted: Thu Dec 02, 2021 8:25 am
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