Re: [xsl] Help: Implementing these XSLT File Array X Path snippets with various XML files & Execute in XML Spy?

Subject: Re: [xsl] Help: Implementing these XSLT File Array X Path snippets with various XML files & Execute in XML Spy?
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 Oct 2017 15:20:34 -0000
Hello Alex,

Does XML Spy do XSLT 3.0?

Here's some XSLT 2.0 to start with. Run this on one of your XMLs,
naming the other as $other-doc. Then reverse it.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="2.0">

  <xsl:key name="string-by-val" match="array/string" use="string(.)"/>

  <xsl:variable name="other-doc" select="document('B.xml')"/>

  <xsl:template match="/">
    <xsl:apply-templates
select="//array/string[exists(key('string-by-val',.,$other-doc))]"/>
  </xsl:template>

  <xsl:template match="string">
    <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>

Also try the empty() function in place of the exists() function and
observe the difference.

You might wish to research key() also, especially its third argument.

XSLT 3.0 can be even more succinct (the last template could be made
implicit). Also this barely scratches the surface of what's possible
comparing the XML, once they are keyed together.

Cheers, Wendell

On Mon, Oct 9, 2017 at 9:32 AM, Alex S as.signup@xxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Help: Implementing these XSLT File Array X Path snippets with various XML
> files & Execute in XML Spy?
>
> So its been 10+ years since I played properly with XSLT and I'm rusty and I
> doubt if I will get the full swing back since I haven't coded in years. But
> once in a while I like to experiment.
>
> PS: Special shout outs to M. Kay, W Piez, Dmitry N - Its been more than a
> decade since I banged heads with you on some edgy XSLT/ XML :)  And it was
> such a joy to do so and have your guidance.
>
> In some wierd way, I always think in terms of Hierarchical Trees hence XML
> is the "data schema" that always comes to my mind when creating a "data
> structure". :)
>
> Either way, this is the current experiment.
>
> So, I posted this on SO and got a good answer in terms of Xpath expressions
> I think, I am just rusty on how to implement this Xpath expression in a
> proper XSL file with my XML files & XML Spy.
>
> https://stackoverflow.com/questions/43730689/find-matching-non-matching-elements-between-2-plist-xml-files
>
> Some small working XSL files would really help as I am way rusty.
>
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)



-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^

Current Thread