Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

"Relational" behavior with XML


This topic is 7193 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Nice new hat QuinTech :-]

It's difficult for we FileMaker developers to understand the "template" like mechanism of XSL. Some of what we think would require an explicit loop is already part of its matching ability. It procedes in a linear manner, with its "<xsl:template>" and "<xsl:for-each>" tags, but can also test against or get data anywhere else in the document. It can also put the same data twice, only get some data, and even add data.

The test syntax, [this here=that there, or some other condition] or, in our case above, [that there=this here], can be all kinds of things. The trick is to be able to specify what/where in the hierarchy you want to test against.

The variable was created specifically because when you're "that there" you're no longer "this here," so you need to capture "this here" first (just like setting a global) before you go. You can alternatively use the "current()" function, but that's messier.

If what's in the brackets is a number, or evaluates to a number, instead of being a test, then it specifies the position at which to get data. We could also have solved the problem that way. But that would assume that there was exact symmetry between the Assets and Bequests. Maybe there is?

<xsl:for-each select="Document/Transaction/Client/Matter/Bequests/Bequest">

<xsl:variable name="pos" select="position()"/>

<xsl:element name="AssetTotal">

<xsl:value-of select="AssetPercentage div 100 * ../../Assets/Miscellaneous[$pos]/Value"/>

</xsl:element>

</xsl:for-each>

[Martin, thanks for the compliment. I think I explain things pretty well, sometimes more than I actually know. In that case, I rely on more knowledgeable folks like yourself to correct me :-]

Posted

Wow... so the bracketed code is just a reference to a particular cell within an array? That's a very clever use of the conditional then! I'm impressed!

OR-- does the syntax:

This[../AssetID=$AssID]

translate to "the value of the element 'this' when the value of its sibling element 'AssetID' equals the value of the variable 'AssID'"? I'm just asking so i know when it might be appropriate for me to use it.

I wish i still had some of those elf hats -- everyone seems to like them!

Posted

Wow... so the bracketed code is just a reference to a particular cell within an array? That's a very clever use of the conditional then! I'm impressed!

OR-- does the syntax:

This[../AssetID=$AssID]

translate to "the value of the element 'this' when the value of its sibling element 'AssetID' equals the value of the variable 'AssID'"? I'm just asking so i know when it might be appropriate for me to use it.

I wish i still had some of those elf hats -- everyone seems to like them!

Posted

Wow... so the bracketed code is just a reference to a particular cell within an array? That's a very clever use of the conditional then! I'm impressed!

OR-- does the syntax:

This[../AssetID=$AssID]

translate to "the value of the element 'this' when the value of its sibling element 'AssetID' equals the value of the variable 'AssID'"? I'm just asking so i know when it might be appropriate for me to use it.

I wish i still had some of those elf hats -- everyone seems to like them!

Posted

It's not "or", it's either, depending on what's in the brackets. I think that's the genius of xsl, it manages to do so much with so little special syntax.

If what's in the bracket is a test, then it retrieves the value which matches the test. If what's in the bracket is a number, then the number is used to set the position in the hierarchy for that node in the node set (is this the right terminology?).

The brackets can occur anywhere within the xpath, so from a FileMaker perspective it could be the ROW (record number), it could be the COL (field's position).

From earlier:

Posted

It's not "or", it's either, depending on what's in the brackets. I think that's the genius of xsl, it manages to do so much with so little special syntax.

If what's in the bracket is a test, then it retrieves the value which matches the test. If what's in the bracket is a number, then the number is used to set the position in the hierarchy for that node in the node set (is this the right terminology?).

The brackets can occur anywhere within the xpath, so from a FileMaker perspective it could be the ROW (record number), it could be the COL (field's position).

From earlier:

Posted

It's not "or", it's either, depending on what's in the brackets. I think that's the genius of xsl, it manages to do so much with so little special syntax.

If what's in the bracket is a test, then it retrieves the value which matches the test. If what's in the bracket is a number, then the number is used to set the position in the hierarchy for that node in the node set (is this the right terminology?).

The brackets can occur anywhere within the xpath, so from a FileMaker perspective it could be the ROW (record number), it could be the COL (field's position).

From earlier:

Posted

The test should NOT explicitly use "Miscellaneous."

Got it. I had actually accounted for that when i edited the XSLT based on what you'd said. Glad to see i got it right -- i'm learning. smile.gif

Did you learn all this from Beverly Voth's book, or are you more self-taught? I'm used to just learning things as i go, but this may be one case where it would be better for me to have a larger view. I'd seen you recommend the book at least once before...

Posted

The test should NOT explicitly use "Miscellaneous."

Got it. I had actually accounted for that when i edited the XSLT based on what you'd said. Glad to see i got it right -- i'm learning. smile.gif

Did you learn all this from Beverly Voth's book, or are you more self-taught? I'm used to just learning things as i go, but this may be one case where it would be better for me to have a larger view. I'd seen you recommend the book at least once before...

Posted

The test should NOT explicitly use "Miscellaneous."

Got it. I had actually accounted for that when i edited the XSLT based on what you'd said. Glad to see i got it right -- i'm learning. smile.gif

Did you learn all this from Beverly Voth's book, or are you more self-taught? I'm used to just learning things as i go, but this may be one case where it would be better for me to have a larger view. I'd seen you recommend the book at least once before...

Posted

I definitely learned quite a lot from Beverlys Voth's book. It is a "must read" if you work with FileMaker and XSL. It jumps right in, so it may be a bit stiff for raw beginners with no knowledge of XML at all (some of us); but this makes it also a good read for those with some knowledge, but not enough (most of the rest of us).

Here are the example files from her book (from an email from her to another mailing list):

Free download of _all_ example files:

http://www.moonbow.com/xml/

I've also been messing about with this off and on (mostly off) for years. There is a fair amount of info online on various xml sites. The problem is that there just aren't many examples of intermediate templates, especially well-documented ones. There are the examples at FileMaker's site, which are well-documented, if you already have some idea what they're doing.

I also have a beginner-intermediate book on XSL, "Sams Teach Yourself XSLT in 21 Days" (been about 6 months and counting :-). I got it from Amazon for about $10, 'cause it's kind of old. It's good, explains everything, slowly :-) You really need a basic book like this, because XSL is a logical language of its own, with many capabilities not covered in Beverly's book (the only FileMaker XML book).

A fair amount of my "learning" has been hours of trial and error (still is); trying what I think might work, seeing what I get, then trying again.

I really need another book, something like "problems and solutions using XSL and FileMaker." Maybe someday Beverly will write volume 2 :-]

Posted

I definitely learned quite a lot from Beverlys Voth's book. It is a "must read" if you work with FileMaker and XSL. It jumps right in, so it may be a bit stiff for raw beginners with no knowledge of XML at all (some of us); but this makes it also a good read for those with some knowledge, but not enough (most of the rest of us).

Here are the example files from her book (from an email from her to another mailing list):

Free download of _all_ example files:

http://www.moonbow.com/xml/

I've also been messing about with this off and on (mostly off) for years. There is a fair amount of info online on various xml sites. The problem is that there just aren't many examples of intermediate templates, especially well-documented ones. There are the examples at FileMaker's site, which are well-documented, if you already have some idea what they're doing.

I also have a beginner-intermediate book on XSL, "Sams Teach Yourself XSLT in 21 Days" (been about 6 months and counting :-). I got it from Amazon for about $10, 'cause it's kind of old. It's good, explains everything, slowly :-) You really need a basic book like this, because XSL is a logical language of its own, with many capabilities not covered in Beverly's book (the only FileMaker XML book).

A fair amount of my "learning" has been hours of trial and error (still is); trying what I think might work, seeing what I get, then trying again.

I really need another book, something like "problems and solutions using XSL and FileMaker." Maybe someday Beverly will write volume 2 :-]

Posted

I definitely learned quite a lot from Beverlys Voth's book. It is a "must read" if you work with FileMaker and XSL. It jumps right in, so it may be a bit stiff for raw beginners with no knowledge of XML at all (some of us); but this makes it also a good read for those with some knowledge, but not enough (most of the rest of us).

Here are the example files from her book (from an email from her to another mailing list):

Free download of _all_ example files:

http://www.moonbow.com/xml/

I've also been messing about with this off and on (mostly off) for years. There is a fair amount of info online on various xml sites. The problem is that there just aren't many examples of intermediate templates, especially well-documented ones. There are the examples at FileMaker's site, which are well-documented, if you already have some idea what they're doing.

I also have a beginner-intermediate book on XSL, "Sams Teach Yourself XSLT in 21 Days" (been about 6 months and counting :-). I got it from Amazon for about $10, 'cause it's kind of old. It's good, explains everything, slowly :-) You really need a basic book like this, because XSL is a logical language of its own, with many capabilities not covered in Beverly's book (the only FileMaker XML book).

A fair amount of my "learning" has been hours of trial and error (still is); trying what I think might work, seeing what I get, then trying again.

I really need another book, something like "problems and solutions using XSL and FileMaker." Maybe someday Beverly will write volume 2 :-]

Posted

My favorite is Michael Kay's XSLT : Programmer's Reference, 2nd ed., Wiley Publishing, 2003, ISBN 0-7645-4381-4. It's thick (939 pages), it's from one of the authors of XSLT, it's not about FM XML and XSLT, but it's both a general introduction and a reference, it explains every function in-depth with examples and has a large appendix that covers XML and XSLT products. Beverly Voth's book is good for learning, but not as a reference. And it does not cover FMS7A and Custom Web Publishing.

As I have understood, XSLT is a so-called functional language. It works like a mathematical function: y=f(x) (in analogy: output = XSLT(XML input)). It should not matter what you pass as x and in which order you pass x (or a more complicated expression) to the function f, one should always get a result y (sometimes not as expected smirk.gif). Therefore XSLT is designed to have no side-effects. Hence it's different from other programming languages like C, Java, JavaScript, Fortran and similar, and one has in part to throw overboard some techniques that one has learnt with the languages mentioned.

Examples and techniques are covered in Sal Mangano's XSLT Cookbook, O'Reilly, 2003, ISBN 0-596-00372-2.

A lot of problems and solutions are discussed in the XSLT FAQ.

And then there is this forum here ...

Martin

Posted

My favorite is Michael Kay's XSLT : Programmer's Reference, 2nd ed., Wiley Publishing, 2003, ISBN 0-7645-4381-4. It's thick (939 pages), it's from one of the authors of XSLT, it's not about FM XML and XSLT, but it's both a general introduction and a reference, it explains every function in-depth with examples and has a large appendix that covers XML and XSLT products. Beverly Voth's book is good for learning, but not as a reference. And it does not cover FMS7A and Custom Web Publishing.

As I have understood, XSLT is a so-called functional language. It works like a mathematical function: y=f(x) (in analogy: output = XSLT(XML input)). It should not matter what you pass as x and in which order you pass x (or a more complicated expression) to the function f, one should always get a result y (sometimes not as expected smirk.gif). Therefore XSLT is designed to have no side-effects. Hence it's different from other programming languages like C, Java, JavaScript, Fortran and similar, and one has in part to throw overboard some techniques that one has learnt with the languages mentioned.

Examples and techniques are covered in Sal Mangano's XSLT Cookbook, O'Reilly, 2003, ISBN 0-596-00372-2.

A lot of problems and solutions are discussed in the XSLT FAQ.

And then there is this forum here ...

Martin

Posted

My favorite is Michael Kay's XSLT : Programmer's Reference, 2nd ed., Wiley Publishing, 2003, ISBN 0-7645-4381-4. It's thick (939 pages), it's from one of the authors of XSLT, it's not about FM XML and XSLT, but it's both a general introduction and a reference, it explains every function in-depth with examples and has a large appendix that covers XML and XSLT products. Beverly Voth's book is good for learning, but not as a reference. And it does not cover FMS7A and Custom Web Publishing.

As I have understood, XSLT is a so-called functional language. It works like a mathematical function: y=f(x) (in analogy: output = XSLT(XML input)). It should not matter what you pass as x and in which order you pass x (or a more complicated expression) to the function f, one should always get a result y (sometimes not as expected smirk.gif). Therefore XSLT is designed to have no side-effects. Hence it's different from other programming languages like C, Java, JavaScript, Fortran and similar, and one has in part to throw overboard some techniques that one has learnt with the languages mentioned.

Examples and techniques are covered in Sal Mangano's XSLT Cookbook, O'Reilly, 2003, ISBN 0-596-00372-2.

A lot of problems and solutions are discussed in the XSLT FAQ.

And then there is this forum here ...

Martin

This topic is 7193 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.