xslt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niarj
    New Member
    • Jan 2008
    • 6

    xslt

    hi,
    do any one have any idea of xslt.

    i have made a xsl file , like

    <!-- Condtions for //es-inhalt-eu/rubrum Path -->
    <xsl:for-each select="//es-inhalt-eu/rubrum">
    <es-inhalt-eu>
    <xsl:element name = "es-inhalt-eu-block">
    <xsl:attribut e name ="typ">rubru m
    </xsl:attribute>
    <xsl:copy-of select ="//es-inhalt-eu/rubrum/node()"/>
    </xsl:element>
    </es-inhalt-eu>
    </xsl:for-each>


    when i execute this it gives me only the nodes formatted in the
    xpath mentioned //es-inhalt-eu/rubrum in the code but i want all the nodes in a xml file plus the output of my xsl file .

    any help ??
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Could you post your source xml, and expected xml?

    It's hard to tell but my guess from what you've posted so far would be:
    Code:
    <!-- Condtions for //es-inhalt-eu/rubrum Path --> 
    <xsl:for-each select="//es-inhalt-eu/*">
    <es-inhalt-eu>
    <xsl:element name = "es-inhalt-eu-block">
    <xsl:attribute name ="typ"><xsl:value-of select="name()"/>
    </xsl:attribute> 
    <xsl:copy-of select ="."/> 
    </xsl:element>
    </es-inhalt-eu>
    </xsl:for-each>

    Comment

    • niarj
      New Member
      • Jan 2008
      • 6

      #3
      SUPPOSE THIS IS MY XML FILE.

      <niraj>
      <ABDC>
      < AB typ="abc">
      <abc>
      <movie> INDIA <movie>
      </abc>
      </AB>
      </ABCD>
      <jha>
      <1234>
      < 12 >
      <abc>
      <movie> run <movie>
      </abc>
      </12>
      </1234>

      <4567>
      < 15 typ="abcd">
      <abc>
      <movie> troy <movie>
      </abc>
      </ 15>
      </4567>
      </jha>
      </niraj>

      I WANT TO FORMAT THIS TAG
      <1234>
      < 12 >
      <abc>
      <movie> run <movie>
      </abc>
      </12>
      </1234>

      BY
      <1234>
      < 12345 TYP="ABCDE">
      <abc>
      <movie1>RUN <movie1>
      </abc>
      </12345>
      </1234>

      SO WHEN I WRITE CODE FOR FORMATTING THIS IT SHOULD BE LIKE .

      <xsl:for-each select="//1234/12">
      <1234>
      <xsl:element name = "12345">
      <xsl:attribut e name ="typ">ABCDE
      </xsl:attribute>
      <xsl:copy-of select ="//1234/12/node()"/>
      </xsl:element>
      </1234>
      </xsl:for-each>

      THIS CODE GIVE ME ANOTHER OUTPUT XML?
      <1234>
      < 12345 TYP="ABCDE">
      <abc>
      <movie1>RUN <movie1>
      </abc>
      </12345>
      </1234>


      BUT I WANT WHOLE XML OUT AS PREVIOUS ONE BUT WITH THE SPECIFIED TAG MODIFIED. LIKE THIS

      MODIFIED TAG WITH ALL PARENT TAGS IN IT
      <niraj>
      <ABDC>
      < AB typ="abc">
      <abc>
      <movie> INDIA <movie>
      </abc>
      </AB>
      </ABCD>
      <jha>


      <1234>
      < 12345 TYP="ABCDE">
      <abc>
      <movie1>RUN <movie1>
      </abc>
      </12345>
      </1234>

      <4567>
      < 15 typ="abcd">
      <abc>
      <movie> troy <movie>
      </abc>
      </ 15>
      </4567>
      </jha>
      </niraj>

      I WANT TO FORMAT THIS TAG
      <1234>
      < 12 >
      <abc>
      <movie> run <movie>
      </abc>
      </12>
      </1234>

      BY
      <1234>
      < 12345 TYP="ABCDE">
      <abc>
      <movie1>RUN <movie1>
      </abc>
      </12345>
      </1234>

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        [code=xml]
        <xsl:template match="1234">
        <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:attribut e name="type" select="'12345' "/>
        </xsl:apply-templates/>
        </xsl:copy>
        </xsl:template>
        <xsl:template match="*">
        <xsl:copy>
        <xsl:copy-of select="@*"/>
        </xsl:apply-templates/>
        </xsl:copy>
        </xsl:template>
        [/code]

        Comment

        Working...