Jump to content
Server Maintenance This Week. ×

Importing from a repeating field in an onix xml file


zeddyblue

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

Recommended Posts

  • Newbies

Hi all, 

I have modified a solution I found in these forums to put together this StylesheetZD2.xsl to extract data from the attached input file AUSdelta152761211111.xml (onix), but I am having trouble figuring out how to import data from a repeating field.

For example, with this stylesheet I can only extract the first "contributor"

<COL><DATA><xsl:value-of select="contributor/b035"/></DATA></COL>
<COL><DATA><xsl:value-of select="contributor/b038"/></DATA></COL>
<COL><DATA><xsl:value-of select="contributor/b039"/></DATA></COL>
<COL><DATA><xsl:value-of select="contributor/b040"/></DATA></COL>
<COL><DATA><xsl:value-of select="contributor/professionalaffiliation/b046"/></DATA></COL>
<COL><DATA><xsl:value-of select="contributor/b044"/></DATA></COL>

But in the example below there are 4 contributors with the same tags.


<contributor>

<b035>A01</b035>

<b039>E A</b039>

<b040>Wrigley</b040>


<persondate>

<b305>007</b305>

<j260>05</j260>

<b306>1931</b306>

</persondate>


<professionalaffiliation>

<b046>University of Cambridge All Souls College, Oxford All Souls College, Oxford All Souls College, Oxford University of Cambridge University of Cambridge University of Cambridge University of Cambridge University of Cambridge All Souls College, Oxford</b046>

</professionalaffiliation>

<b044>Sir Tony Wrigley is a member and co-founder of the Cambridge Group for the History of Population and Social Structure and a former President of the British Academy. His previous publications include Population and History (1969), People, Cities and Wealth (1987), Continuity, Chance and Change (1988), Poverty, Progress, and Population (2004), and, with R. S. Schofield, The Population History of England 1541 1871 (1981).</b044>

</contributor>


<contributor>

<b035>A01</b035>

<b039>R S</b039>

<b040>Davies</b040>


<professionalaffiliation>

<b046>University of Cambridge</b046>

</professionalaffiliation>

</contributor>


<contributor>

<b035>A01</b035>

<b039>J E</b039>

<b040>Oeppen</b040>


<professionalaffiliation>

<b046>University of Cambridge</b046>

</professionalaffiliation>

</contributor>


<contributor>

<b035>A01</b035>

<b039>R S</b039>

<b040>Schofield</b040>


<professionalaffiliation>

<b046>University of Cambridge</b046>

</professionalaffiliation>

</contributor>

 

Ideally, I would like to have multiple columns in my table for each "contributor". Can anyone give me any advice on how to modify the stylesheet so that I can extract the other data?

Link to comment
Share on other sites

15 minutes ago, zeddyblue said:

Ideally, I would like to have multiple columns in my table for each "contributor".

No, I don't think you would want that. It would be very poor structure to have. Just as an example: if you wanted to search for a product by contributor, you would have to enter the same search criteria into each and every one of the "contributor" fields.

Ideally, you would have a related Contributors table, and you would either import the XML data twice - once into Products and once into Contributors, each importing its own set of fields - or import first into a temp "flat" table (where each contributor would be a record that also includes all the parent product data), and from there into the two target tables.

The first option requires that each product in the XML has a unique and permanent ID that can be used to relate the two tables.
The second option assumes that each product has at least one contributor.

Link to comment
Share on other sites

  • Newbies

Thanks Comment, 

Having a separate table would also make it easier to handle the different number and type of contributors for each book, i.e., author, editor, illustrator, etc. I have been so fixated on exporting all the data I didn't even think about the best way to use the data.  I am new to relational databases so thanks for steering me in the right direction. 

Link to comment
Share on other sites

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