0

Now I have a more complicated situation than I asked about in In XSLT for MODS XML to FilemakerPro conversion, how treat a mod with a parameter? . In the XML I'm trying to convert to FileMaker Pro format, I have:

<name type="personal">
   <namePart type="family">
      Giobbi
   </namePart>
   <namePart type="given">
      Robert
   </namePart>
   <role>
      <roleTerm authority="marcrelator" type="code">
         aut
       </roleTerm>
   </role>
</name>

What do I put in the XSLT for the <xsl:value-of select="...." /> to handle that. The new complications are:

  1. The source XML has a nested structure with several elements inside name.
  2. For item roleTerm there are two parameters authority and code.

In the resulting XML, I want separate columns for "family" and "given" names and for the roleTerm.

Also, in some situations, there will be two or more such <name>...</name> entities. How do I handle that -- so as to create additional columns in the target XML? Is it as simple as changing MAXREPEAT from "1" to a greater value?

The desired output should be something like the following:

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"    
     xmlns:mod="http://www.loc.gov/mods/v3">
   <ERRORCODE>0</ERRORCODE>
   <PRODUCT NAME="N/A" BUILD="N/A" VERSION="N/A"/>
<DATABASE NAME="N/A" LAYOUT="N/A" RECORDS="1" DATEFORMAT="M/d/yyyy" TIMEFORMAT="h:mm:ss a"/>
<METADATA>
  <FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="Title"/>
  <FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="Genre"/>
  <FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="LastName"/>
  <FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="FirstName"/>
</METADATA>
<RESULTSET>
  <ROW MODID="1" RECORDID="1">
    <COL>
      <DATA>Roberto Giobbi's Card college. Volume 1</DATA>
    </COL>
    <COL>
      <DATA>book</DATA>
    </COL>
    <COL>
      <DATA>Giobbi</DATA>
    </COL>
    <COL>
      <DATA>Roberto</DATA>
    </COL>
  </ROW>
</RESULTSET>
</FMPXMLRESULT>

I say "something like" that because of course there will be more rows, one for each item in the source XML, and more importantly because I don't know what the result should look like when there is more than one field of the form <name type="personal">...</name> in the source (.e., multiple authors in the bibliographic source xml file).

Community
  • 1
  • 1
murray
  • 737
  • 2
  • 10
  • 28
  • Could you add an example of the resulting xml you want to produce? – Joep Mar 27 '13 at 14:27
  • I don't know what the resulting xml should look like: it's supposed to be in the FMPRESULT format. Without these new mod items I'm asking about, I was able to use `xsltproc` with a minimal XSLT to obtain an XML that I don't know how to display in my query: in a text editor, the output is on a single very long line; in an XML editor I have a structure shown, but I don't know how to put that here. – murray Mar 27 '13 at 15:16
  • You could edit your question, then you have the possibility to format this as code. Use something like http://www.freeformatter.com/xml-formatter.html to format you single line of XML. – Joep Mar 27 '13 at 15:35
  • Still not clear what has to go where... – Joep Mar 27 '13 at 15:38
  • @Joepie: What I did was take my original XSLT, convert the source XML with that, opened it in Safari, copied directly to my edited question here, then added manually what I presume the additional `` elements will look like. (Of course that still left me to do the by hand the indenting-4-spaces business to get the pasted stuff to display as code.) – murray Mar 27 '13 at 15:40
  • I'm pretty sure that the format I show in the desired resulting XML for the 3rd & 4th`FIELD`s and the corresponding 3rd & 4th `COL`s (author's last & first names) are what I want. The first question is the syntax in the XSLT to handle that from the source XML. The second question is what to do in the case of more than one author; I presume I just want a pair of additional `COL`s for each such additional, but I don't know what that would look like in the resulting XML output. – murray Mar 27 '13 at 16:11

1 Answers1

0

Example selections for every text content:

Repeating COL's:

<xsl:for-each select="name">
    <ROW MODID="{position()}" RECORDID="{position()}">
        ...
    </ROW>
</xsl:for-each>

For selecting family name:

<xsl:value-of select="namePart[@type='family']"/>

For generating

<xsl:value-of select="namePart[@type='given']"/>

For selecting roleTerm

<xsl:value-of select="roleTerm[@authority='marcrelator' and @type='code']"/>
Joep
  • 4,003
  • 3
  • 28
  • 32