Announcement

Collapse
No announcement yet.

wie schreibe ich diese Bedingungen in <xsl:apply-templates select="???">

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • wie schreibe ich diese Bedingungen in <xsl:apply-templates select="???">

    meine xml Datei
    ....
    <loops>
    <loop no="1" deltaxml:delta="WFmodify">
    <Element1 deltaxml:delta="WFmodify"/>
    <Element1 deltaxml:delta="unchanged"/>
    </loop>
    <loop no="2" deltaxml:delta="WFmodify">
    <Element1 deltaxml:delta="WFmodify"/>
    <Element2 deltaxml:delta="WFmodify"/>
    </loop>
    <loop deltaxml:delta="WFmodify"
    old-attributs="no=&quot;3&quot;" new-attributs="no=&quot;4&quot;">
    <Element1 deltaxml:delta="unchanged"/>
    <Element2 deltaxml:delta="unchanged"/>
    </loop>
    <loop no="5" deltaxml:delta="unchanged" >
    <Element1 deltaxml:delta="unchanged"/>
    <Element2 deltaxml:delta="unchanged"/>
    </loop>
    </loops>
    ....

    die gewünschte xml Datei nach xsl Transformation
    ....
    <modified>
    <loop no="1"/>
    <loop no="2"/>
    </modified>
    <renamed>
    < loop oldVariable="no=&quot;3&quot;"
    newVariable="no=&quot;4&quot;">
    </renamed>
    <unchanged>
    <loop no="5">
    </unchanged>
    ....

    Die Bedingungen sind, falls die Attribut von loop gleich "deltaxml.delta='WFmodify'" ist, und die Attribut von ihren Elementn gleich "deltaxml.delta='unchanged'" ist, dann ist diese loop zu <renamed> gehören. Falls die Attribute von loop und ihren Elementen gleich "unchanged" sind, gehört sie zu <unchanged>, sonst ist <modified>,

    Ich habe wie folgende xsl geschrieben.
    <xsl:template match="loops" >
    <xsl:copy>
    <xsl:element name="modified">
    <xsl:apply-templates select="......"/>
    </xsl:element>
    <xsl:element name="renamed">
    <xsl:apply-templates select="......"/>
    </xsl:element>
    <xsl:element name="unchanged">
    <xsl:apply-templates select="loop[@deltaxml:delta='unchanged']"/>
    </xsl:copy>
    </xsl:template>
    <xsl:template match="loop">
    <xsl:copy>
    <xsl:apply-templates select="@no"/>
    </xsl:copy>
    </xsl.template>
    ......

    Die Frage ist, wie ich Element <modified> und <renamed> in XSLT definieren?

  • #2
    Hallo,

    hier schicke ich Dir die Lösung:

    <xsl:template match="loops" >
    <xsl:copy>
    <xsl:element name="modified">
    <xsl:apply-templates select="//loop[@deltaxml:delta = 'WFmodify' and count(*[@deltaxml:delta='unchanged']) != count(*)]"/>
    </xsl:element>
    <xsl:element name="renamed">
    <xsl:apply-templates select="//loop[@deltaxml:delta = 'WFmodify' and count(*[@deltaxml:delta='unchanged']) = count(*)]"/>
    </xsl:element>
    <xsl:element name="unchanged">
    <xsl:apply-templates select="//loop[@deltaxml:delta = 'unchanged' and count(*[@deltaxml:delta='unchanged']) = count(*)]"/>
    </xsl:element>
    </xsl:copy>
    </xsl:template>

    <xsl:template match="loop">
    <xsl:copy>
    <xsl:copy-of select="@no"/>
    <xsl:if test="@old-attributs">
    <xsl:attribute name="oldVariable"><xsl:value-of select="@old-attributs"/></xsl:attribute>
    </xsl:if>
    <xsl:if test="@new-attributs">
    <xsl:attribute name="newVariable"><xsl:value-of select="@new-attributs"/></xsl:attribute>
    </xsl:if>
    </xsl:copy>
    </xsl:template>

    bis dann... Matthias

    Comment


    • #3
      Danke!

      Comment

      Working...
      X