Subject:Probably simple but.... Author:Mike Sapp Date:15 Mar 2007 02:44 AM Originally Posted: 14 Mar 2007 10:24 AM
Hi all-
Am extremely new to this so please be patient with me---
Am mapping from a clients XML to our XML using stylus and have come up against an interesting issue. It seems that the clients XML refers to another element using reference="" . As i had mentioned, im really very new to XSLT and have racked the condition and instruction info in the help section of Stylus's documentation.
A copy of their xml is below:
<album>
<track>
<contributor reference="CR26272">
<role>Composer</role>
</contributor>
<contributor reference="CE9682">
<role>Main Artist</role>
</contributor>
<contributor reference="CR26272">
<role>Writer</role>
</contributor>
</track>
</album>
=====XML keeps going for each individual <track>====
and then on the bottom....
I want to get the name of the Composer when the role "Composer" is present...... The Track element in the source XML is a repeating element and sometimes the role "Composer" element is present and sometimes not...
It would map to a single Composer attribute in the target xml. <xsl:attribute name="Composer">
Any help in clearing up this probably very easy problem would be greatly appreciated-.
Sorry for the hassle and i hope that my question made sense!
Subject:Probably simple but.... Author:Mike Sapp Date:15 Mar 2007 10:39 AM Originally Posted: 15 Mar 2007 10:27 AM
Hi-! Thank you very much for the fast reply. The code was a No go :( As i had said, i really am new to this :( While reading your quick reply helped me learn a little bit, im still stumped....
Below is the full XML that i need to get the info from. On the bottom is ours. I just need to somehow get the name into the composers field on our XML.
As you can see, the contributor element containing the referred ID CR30962 is on the bottom. Im trying to get Billy Blue (CR30962) to our composer attribute in our XML :(
Sorry for uploading all of this code, but anything that can help you assess the situation better is extremely appreciated. Obviously the problem is that i cant seem to get the referring data in the first XML regarding the tracks composer to match up to our composer attribute field in the second xml. As i had mentioned before, im extremely new to using Stylus Studio and started using it because of the GUI and ease of use for doing simple click and drag xsl:attribute name= -> value of transformations with the mapper.... :(
Subject:Probably simple but.... Author:(Deleted User) Date:15 Mar 2007 11:37 AM
Hi Mike,
given the structure of the XML you want to get, this is something that should help. However, I could not find out the mapping for some fields, so you will have to finish the job ;-)
Subject:Probably simple but.... Author:Mike Sapp Date:16 Mar 2007 11:15 AM Originally Posted: 16 Mar 2007 10:37 AM
Hello Alberto-
Tried and tried to get it to work and didnt have any success :( Have also tried variations on the xpath which you laid out and no luck :( Im sure that this is definately due to my inexperience with xpath etc- Ive summed up their XML below. Im also putting the code that i have used so far-- Thank you for your help!
Subject:Probably simple but.... Author:(Deleted User) Date:19 Mar 2007 09:22 AM
Hi Mike,
the XSL you wrote was very different from the one I have posted (it creates a single <track> but then adds all the composers to its value), while the last two examples never look at the current track...
As you can see, the "composer" and the "lyricist" attributes of the "track" element are set to "Stefan Gohild", and the "artistName" is "Stabilizer". You just need to add the code to copy over the rest of the attributes (WAV file, photo, etc..)
Subject:Probably simple but.... Author:Mike Sapp Date:20 Mar 2007 10:02 AM
Hi Alberto-
I copied your template and for some reason im not getting any preview data at all when i click on the Preview Result button. All of the code that you have provided me looks fine, but im not sure if is the processor problem or not? Im really stumped...
Do you think it has to do with the declaration?
PS- Thank you VERY VERY much for all of your help so far and your patience with me for being a noob-
Subject:Re: Probably simple but.... Author:Mike Sapp Date:20 Mar 2007 10:40 AM Originally Posted: 20 Mar 2007 10:39 AM
I have.
Also, I can edit the rest of the fields, but if i was to take the exact same code that you supplied and do a re-write (of the xsl file) matching it to another XML (produced by the same source); essentially copying the XSL you provided, i dont get any results....
Also, ive tried running the XSL that you showed me against other files from the same source with no results... The code all looks to make sense and this is why im so stumped-
It always seems to hang at
<?xml version="1.0" encoding="utf-8"?><document/> when displaying the transformed data
Subject:Re: Probably simple but.... Author:(Deleted User) Date:20 Mar 2007 11:00 AM
Mike,
if you get just an empty <document> node it means that the first loop in the XSLT (<xsl:for-each select="submission/album">) is not extracting any data. Please verify if the source XML really has a <submission> root node, followed by an <album>; also, verify if these new files are using a default namespace.
Subject:Re: Probably simple but.... Author:(Deleted User) Date:20 Mar 2007 11:27 AM
Mike,
their namespaces are not "generic"; this XML is the first that shows the namespace attribute xmlns="http://schemas.XXXX.com/XXXXX/XXXXX_1_1.xsd"
This means that the XSLT must have a namespace attribute like xmlns:x="http://schemas.XXXX.com/XXXXX/XXXXX_1_1.xsd" at the <xsl:stylesheet> node, and all the XPath queries like "submission/album" must be changed into "x:submission/x:album".