Thanks Gerrit, your useful tips made it work now.
One more thing:
In the source xml I hava the attribute "note" and "noteAdditions" that I
want to combine together joined by another attributes value:
<source note="hello" noteAdditions="world" expert="HAHA">
<result note="hello
HAHA:world">
On Thu, Jun 19, 2014 at 7:27 AM, Imsieke, Gerrit, le-tex
gerrit.imsieke@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> On 19.06.2014 03:33, Philipp Kursawe phil.kursawe@xxxxxxxxx wrote:
>
>> The resulting XML should contain only 2 attributes from "InspectionExt"
>> in case result="10" or "11" otherwise all attributes and "Obligations",
>> "Defects" but no "Photo"
>> Also when copying the Defects/Defect items, only those with
>> "not(@reinspection='ok'" should be copied over. No "Defects" element
>> should be created if nothing from source xml is copied.
>> The resulting "Defect" element must not contain the "reinspection"
>> attribute.
>>
>> That's what I came up with after your suggestions:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:fn="http://www.w3.org/2005/xpath-functions">
>> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
>>
>> <xsl:template match="InspectionExt">
>> <xsl:element name="ns2:InspectionReportInput"
>> namespace="http://somenamespace">
>> <xsl:choose>
>> <xsl:when test="@result eq '10' or @result eq '11'">
>>
>
> In XPath 1, there is no eq operator. Use = instead.
>
>
> <xsl:copy-of select="@result"/>
>> <xsl:copy-of select="@expert"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:copy-of select="@*[not(@signed)]"/>
>> <xsl:for-each select="Defects">
>> <xsl:element name="Defects">
>> <xsl:for-each select="Defect[not(@reinspection='ok')]">
>> <xsl:element name="Defect">
>> <xsl:copy-of select="@*[not(@reinspection)]"/>
>>
>
> You are selecting all attributes that don't have a reinspection attribute
> attached to them. Since no attribute carries other attributes, your
> predicate is always true. Use @*[not(name() = 'reinspection')] instead.
>
> Gerrit
| <- Previous | Index | Next -> |
| Re: Copy all attributes excep, Imsieke, Gerrit, le-
|
Thread |
Re: Copy all attributes excep, Imsieke, Gerrit, le-
|
| Re: Copy all attributes excep, Imsieke, Gerrit, le-
|
Date |
Re: Copy all attributes excep, Imsieke, Gerrit, le-
|
|
Month |
|
|