My xsl to map the nl:AdditionalRequirement if the requirementTitle attribute is "plaatsingsnummer":
<xsl:for-each select="a:UserArea/nl:StaffingAdditionalData/nl:CustomerReportingRequirements">
<Description>
<xsl:choose>
<xsl:when test="a:UserArea/nl:StaffingAdditionalData/nl:CustomerReportingRequirements/nl:AdditionalRequirement/@requirementTitle = 'plaatsingsnummer'">
<xsl:text>plaatsingsnummer exists</xsl:text>
</xsl:when>
<xsl:otherwise>no plaatsingsnummer</xsl:otherwise>
</xsl:choose>
</Description>
</xsl:for-each>
If I skip the for each I at least get a message "no plaatsingsnummer", but there is one, so how can I map it?
Subject:Select one of multiple attributes? Author:(Deleted User) Date:08 Dec 2008 03:25 PM
Hi Cynthia,
inside the for-each instruction, your current element is now one of the a:UserArea/nl:StaffingAdditionalData/nl:CustomerReportingRequirements elements, so the inner test must be done only using nl:AdditionalRequirement/@requirementTitle = 'plaatsingsnummer'.
Subject:Select one of multiple attributes? Author:(Deleted User) Date:08 Dec 2008 04:26 PM
Hi Alberto,
I tried it with the for each round the Description element and inside but then I get no tag at all in the result. Without the for each I at least get a result (no plaatsingsnummer).
I am still doubting the for each though I think I should use it as the nl:AdditionalRequirement can occur multiple times. If I use a straight link in the mapper to see if I at least can see the value of element I also get no result. What am I missing?
Last tested (with the for each inside and around the element):
<xsl:for-each select="a:UserArea/nl:StaffingAdditionalData/nl:CustomerReportingRequirements">
<xsl:choose>
<xsl:when test="nl:AdditionalRequirement/@requirementTitle = 'plaatsingsnummer'">
<xsl:text>plaatsingsnummer exists</xsl:text>
</xsl:when>
<xsl:otherwise>no plaatsingsnummer</xsl:otherwise> </xsl:choose>
</xsl:for-each>
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 02:46 AM
Hi Cynthia,
if the for-each is not even entering the loop (i.e. if you are not seeing anything by executing the code) it could be that the XPath expression shouldn't start with a:UserArea; can you attach the source XML, and the XSLT code preceding this fragment?
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 05:10 AM
Hi Alberto,
Could it be that there is a problem with all nl: prefixed elements, since non of these mapped elements gives a result. The location of the prefix namespace (xmlns:nl="http://ns.hr-xml.org/2004-08-02) does not work, is that the problem?
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 06:20 AM
Hi Cynthia,
the problem is not with the "nl" prefix, as its URI must not be a valid URL (it could be any string). The problem is that your XML has two levels of Line elements, and your current code is picking the outermost. That is, you have a Line sibling of Header, that has three children, LineNumber, Charges and Line; it's this last Line element the one that has a UserArea element as its last child.
So, probably you should write a recursive algorithm by having a separate template for Line elements; but in case you know you are always dealing with a two-level structure, you can change your XSL to say
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 02:36 PM
Hi Alberto,
Changed the for each a little bit and now it is working if I not use a value of select, but just print a text in the when clause, for instance "plaatsingsnummer". I then correctly get three times "no plaatsingsnummer" and 1 time "plaatsingsnummer". The value of select is still not working though, does it have to do something with the fact that I am already inside the "nl:AdditionalRequirement" tag and I should only select the attribute itself?
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 03:46 PM
Cynthia,
the for-each instruction selects the node identified by its XPath expression as the current node; so, the value-of located inside its scope must not re-navigate to locate it, and can just be <xsl:value-of select="text()"/> (as the filtering was done by the parent xsl:when instruction).
Subject:Select one of multiple attributes? Author:(Deleted User) Date:09 Dec 2008 04:50 PM
Hi Alberto,
I am still progressing, I now moved on to an error about not finding a scema it wants to include. Error text:
---------------------------
Stylus Studio 2008 XML Enterprise Suite Release 2
---------------------------
Error: at xsd:include on line 17 of file:///e:/Klanten/SROL/VOORBE%7E1/InvoiceAdditionalNL.xsd:
Failed to process included schema document ../StaffingOrganization.xsd
URL: file:///e:/Klanten/SROL/VoorbeeldFactuur/20080121_114332.100167.4529093.10001.982205.12601217.INVOICE.xml
Line:15
Col: 38
Jump to location?
---------------------------
Yes No
---------------------------
Now I think I should place the StaffingOrganization.xsd one directory up from the location of InvoiceAdditionalNL.xsd, but it doesn't resolve the error. Could it be because this new schema (StaffingOrganization.xsd) is including itself a few new schema's as well?
Subject:Select one of multiple attributes? Author:(Deleted User) Date:12 Dec 2008 05:58 AM
Cynthia,
the zip file you provided was already missing a couple of schemas, so I cannot tell which ones you need to fully construct them. You will have to follow the error messages in telling what is missing and where it expects them to be located.