i want to transform a xml with the XSLTProcessor. Everthing is working fine but i got problems with the attribute-sets.
My XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<exportDelivery>
<job>/* many other tags and data */</job>
<job>/* many other tags and data */</job>
<job>/* many other tags and data */</job>
</exportDelivery>
If you want to use attributes in your new xml you have to use attribue-sets in the xsl-file. But attribute-sets have to be defined in the “head” of the xsl. that means outside of the foreach-loop for the “job”-tags.
After the Transformation every job gets the same attributes of the first job. What did i wrong? Here is a attribue-set i use:
<xsl:attribute-set name="premium">
<xsl:attribute name="from">
<xsl:value-of select="/exportDelivery/jobAdvertisements/startDate"/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select="/exportDelivery/jobAdvertisements/endDate"/>
</xsl:attribute>
</xsl:attribute-set>
Thanks!
attribute-sets are used as a shorthand for providing multiple attributes at once, so instead of writing:
every time we want to specify all three at once, one may specify an attribute-set to do it in one line
These “attribute-sets” can only be defined once.
in your case, don’t you want to do something like this?
if so, i don’t see, what’s stopping you from inserting these elements during the transformation:
maybe you need to explain a little further, what you are trying to achieve exactly