Announcement

Collapse
No announcement yet.

Newbie-Frage... Attributwert verändern

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

  • Newbie-Frage... Attributwert verändern

    Hallo Expert/innen,

    ich habe eine Xml-Datei, die ungefähr so aussieht:

    ...
    <wtf:routingInfo source="..." target="..." topic="prot://foo/bar/someTopic"/>
    ...

    und ich hätte gerne das daraus:

    ...
    <wtf:routingInfo source="..." target="..." topic="prot://foo/bar/someTopic.Remote"/>
    ...

    Ist wahrscheinlich pillepalle für Leute mit Ahnung von XSL, aber alles, was ich finde im Netz, sind XML-nach-HTML-Beispiele.

    Danke für alle Lösungen vorab!

    Carsten

  • #2
    Ansatz:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    
      <xsl:template match="@* | node()">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="@topic[. = 'prot://foo/bar/someTopic']">
        <xsl:attribute name="topic">
          <xsl:value-of select="concat(., '.Remote')"/>
        </xsl:attribute>
      </xsl:template>
    
    </xsl:stylesheet>
    bzw. generischer für beliebige Attribute mit dem genannten Inhalt:

    Code:
      <xsl:template match="@*[. = 'prot://foo/bar/someTopic']">
        <xsl:attribute name="{name()}">
          <xsl:value-of select="concat(., '.Remote')"/>
        </xsl:attribute>
      </xsl:template>

    Comment


    • #3
      Danke sehr!

      Comment

      Working...
      X