Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is there a more efficient way?

Featured Replies

Finally diving into xslt and hoping to learn something...

If I have a node like this:




 Stormy Monday

 Smoke on the Water

 Blue Monk





and there will never be more than one tune of each type of genre, then what is the most efficient way of extracting the jazz element? I  am using this code:



	

		

	

So, the result is "Blue Monk"

But, it seems to me that there is probably a much more efficient way of getting this same result. Any suggestions?

I assume that you don't want to have list that is separated by carriage returns, do you?




  







is shorter. All the jazz items come on one line (as in your previous code), but you can separate them by adding code such as 
 or so.



Even shorter is the following construct:



Let's assume playlist is the root node of your XML fragment:







selects all tune children of playlist with attribute genre = jazz.

Here you can't separate the items.

Selection of elements out of an XML tree or of whole axes is the strength of XPath.

Edited by Guest
If not code tag is used, the forum engine inserts spaces where they are not wanted.

  • Author

Hi Martin,

I used your last example, and it does what I want. I need to parse a fairly large file with a lot of different nodes like the example I gave. So, the shorter I can make the xslt, the better.

Even with the official documentation on XSLT and XPATH, it really helps to have an example.

Thanks for the help.

  • Author

Hmm, I seem to have another problem now. Suppose I have a node like this with the genre attribute missing from one of the elements:


 Happy Birthday

 Stormy Monday

 Smoke on the Water

 Blue Monk







Now I want to extract only the tune element that has no genre attribute. So, in this example I want to get: "Happy Birthday"



I tried:





but it doesn't work. Then, I thought Xpath might have an Exists() function so that I could use something like "not(Exists(tune/@genre))", but couldn't find anything like that. How would I handle this?


Works. Don't know if there's a better way.

  • Author

Thanks Fenton. As it turns out, some XSLT translators will work with the expression that I had tried, but not Filemaker's. Anyway, your's does the trick.

BTW, thank you for your past postings of XSL examples. I'm making great use of them on my current project.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.