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

Probably a simple issue (XSLT)


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

Recommended Posts

Posted

Hi all - Very much a newbie to XML/XSLT in Filemaker, so I'm not even sure if I will be supplying the proper info here. I'm trying to create a stylesheet in order to import data from a file that has info formatted like this:

PS3569.T3868

C79 1999

Assuming I want the PS3569.T3868 info imported, how do I reference just that field in the stylesheet? I've played around with variations of this:

and

But these don't seem to work (the second one returns just the letter "a" but it makes me feel like I'm on to something ;)

Thanks in advance for advice and help. Again, I'm very new to this so let me know if more details are required.

Posted

It should look approximately* like this:

See the 'Predicates' section here:

http://www.w3schools.com/XPath/xpath_syntax.asp

---

(*) I cannot tell the path to the element without seeing the entire document. In general, it's more efficient to specify the path explicitly instead of using the "wherever" // axis.

Posted

Thanks so much for the response. I will try your suggestions. Also thank you for including the link, that is going to be very helpful as well.

FYI - here is the full XML file that I'm working with...

bibliographic.zip

Posted

Sorry to have to come back to the well on this one but I just can't seem to get this import to work.

I'm attaching both my original XML file and my attempts at building an appropriate XSLT file. I have modified the "xsl:value-of select=" tag about 200 times in an attempt to import the data that lives in the datafield/subfield tags in the XML file.

I either import too much (all the content, in one big dump) or nothing at all. I've included (commented out) some of my attempts to point to these fields. For those who don't want to open the zip file here's the first part of the XML file:

<?xml version="1.0"?>

1.19marcxmlxml

00793pam a2200241 a 4500

6750948

BIBLIOS

20031223191706.0

990108s1999 nyu 000 1 eng

99011685

0380973464 (hardcover) ;)

$27.50 ($39.50 Can.)

(DLC) 99011685

DLC

DLC

DLC

BIBLIOS

PS3569.T3868

C79 1999

And my attempts to grab the "PS3569.T3868" data have looked (at various times) like this:

None of these get what I want which is just that one piece of info. Note - eventually if I figure this one field out I would want to use it for the rest of the XML file to import all the subfields in to their appropriate slot.

Any help would be eternally appreciated! THanks in advance!

Posted

Yeah, well - you've got another issue there: the namespace changes at some point of the hierarchy:

So and all its chidren, incl. and , belong to another namespace. I often wonder why some XML authors need this complexity. Anyway, you need to add this namespace to your element and give it a prefix, say "sl":

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:zs="http://www.loc.gov/zing/srw/"

xmlns:sl="http://www.loc.gov/MARC21/slim"

exclude-result-prefixes="zs sl">

Then you can use it in your path as:


Note that a record (i.e. a sl:record) has many datafield elements, so this will get data from the first one that has a subfield coded "a". What you really should be doing is specify the datafield by its tag attribute.

Posted

By jove it works!

THANK YOU SO MUCH. This seriously makes my day/week/month/year. Plus I feel like I know a lot more about XML/XSLT than when I started, which is a big plus.

Thank you thank you thank you!

This topic is 5601 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.