Re: simplifying transform

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Schwartz

    Re: simplifying transform

    Thanks for your help Martin. I'd like to explore this in steps if
    possible. So when I execute the following transform, I don't get any
    attributes. Any ideas as to why? Shouldn't I get all the nodes in
    their original state?

    <xsl:styleshe et
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:redirect= "org.apache.xal an.xslt.extensi ons.Redirect"
    extension-element-prefixes="redir ect">

    <xsl:template match="@* | node()">
    <redirect:wri te file="transform ed.xml">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </redirect:write>
    </xsl:template>

    TIA!
    David
  • David Carlisle

    #2
    Re: simplifying transform

    David Schwartz wrote:
    Thanks for your help Martin. I'd like to explore this in steps if
    possible. So when I execute the following transform, I don't get any
    attributes. Any ideas as to why? Shouldn't I get all the nodes in
    their original state?
    >
    <xsl:styleshe et
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:redirect= "org.apache.xal an.xslt.extensi ons.Redirect"
    extension-element-prefixes="redir ect">
    >
    <xsl:template match="@* | node()">
    <redirect:wri te file="transform ed.xml">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </redirect:write>
    </xsl:template>
    >
    TIA!
    David
    That template is generating a file (with the same noame over and over
    again) for every element, in the case of attributes it tries to copy the
    attribute on its own to a new file but without an element to hold it,
    that can't work.

    If you just want to redirect the result of an identity transform then
    you don't want a new file on every element, just the root:

    <xsl:template match="@* | node()">

    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>

    </xsl:template>

    <xsl:template match="/">
    <redirect:wri te file="transform ed.xml">

    <xsl:apply-templates/>

    </redirect:write>
    </xsl:template>

    David

    --

    Comment

    • David Schwartz

      #3
      Re: simplifying transform

      Actually, both stylesheets produce a file with the same number of
      elements. The stylesheet you provided David does include the
      attributes though so thanks!

      So, now that I'm successfully creating all the tags, how do I change
      the values of the ref attribute in just the tagC elements?

      Thanks again!

      David

      Comment

      • Martin Honnen

        #4
        Re: simplifying transform

        David Schwartz wrote:
        Actually, both stylesheets produce a file with the same number of
        elements. The stylesheet you provided David does include the
        attributes though so thanks!
        >
        So, now that I'm successfully creating all the tags, how do I change
        the values of the ref attribute in just the tagC elements?
        As suggested earlier:

        <xsl:template match="@* | node()">

        <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>

        </xsl:template>

        <xsl:template match="/">
        <redirect:wri te file="transform ed.xml">

        <xsl:apply-templates/>

        </redirect:write>
        </xsl:template>

        <xsl:template match="@id2"/>

        <xsl:template match="tagC">
        <xsl:copy>
        <xsl:attribut e name="ref">
        <xsl:value-of select="../*[@id2 = current()/@ref]/@id1"/>
        </xsl:attribute>
        <xsl:apply-templates/>
        </xsl:copy>
        </xsl:template>



        --

        Martin Honnen

        Comment

        • David Schwartz

          #5
          Re: simplifying transform

          Thanks for everyone's help! While I wish I understood the stylesheet
          better but it's getting the job done.

          Thanks again,
          David

          Comment

          Working...