xsl-list
[Top] [All Lists]

RE: Eliminating duplicate nodes

2002-10-12 18:33:07


Ok, thanks.

I consider any 2 nodes with the same id to be duplicates.
...and actually, I don't' use call-template just apply-template


So, here's my code....

Thanks again,
mac

<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">
        <body bgcolor="black" text="white">
        <form name="creations" method="get"
action="writeTestRunOptions.asp">
        <table>
                <xsl:for-each select=".">
                                <xsl:apply-templates  />        
                </xsl:for-each>
        </table>
        </form>
        </body>
</xsl:template>

<xsl:template match="panel|comboBox">
        <tr>
        <td>
                <xsl:apply-templates  />
        </td>
        </tr>
</xsl:template>

<xsl:template match="checkBox|button|radioButton">
        <tr>
        <td>
                <xsl:apply-templates  />
                <input type="checkbox" name="{(_at_)id}" value="{node()}"/>
        </td>
        </tr>
</xsl:template>

<xsl:template match="label">
        <tr>
                <td bgcolor="darkred">
                        <font color="red">
                                <xsl:apply-templates  />
                                <xsl:value-of select="@node" />
                        </font>
                </td>
        </tr>
</xsl:template>

<xsl:template match="lineEdit">
        <tr>
        <td>
                 [created automatically]
        </td>
        </tr>
</xsl:template>

<xsl:template match="item">
        <xsl:choose>
                <xsl:when test="position() = 1">
                        <input type="checkbox" value="{node()}"
name="{../@id}" checked="true"/>
                </xsl:when>
                <xsl:otherwise>
                        <input type="checkbox" value="{node()}"
name="{../@id}"/>
                </xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="node()" />
        <br />
</xsl:template>

</xsl:stylesheet>

===============================================================

<main>

  <dialog id="pw">
    <label id="pw.titleBar"></label>
      <panel id="pw.publish">
        <group id="pw.publish.frame">
          <panel id="pw.publish.group">
            <label id="pw.publish.lbl">Publish options:</label>
            <button id="pw.publish.print">Print</button>
            <button id="pw.publish.email">E-mail</button>
          </panel>
        </group>
        <group id="pw.summmary.frame">
          <panel id="pw.summary.group">
            <label id="pw.projectName.lbl">Name:</label>
            <lineEdit id="pw.projectName"></lineEdit>
            <checkBox id="pw.usetitleforname.cb">Use Title for
Name</checkBox>
            <label id="pw.summary.lbl"></label>
            <label id="pw.graphic"></label>
          </panel>
        </group>
      </panel>
      <panel id="pw.template">
        <group id="pw.title.frame">
          <panel id="pw.title.group">
            <checkBox id="pw.title.cb"></checkBox>
            <label id="pw.title.lbl">Title:</label>
            <lineEdit id="pw.title"></lineEdit>
          </panel>
        </group>
        <group id="pw.pages.frame">
          <panel id="pw.pages.group">
            <label id="pw.pages.lbl">Photos Per Page:</label>
            <comboBox id="pw.pages">
              <item>1</item>
              <item>2</item>
              <item>3</item>
              <item>4</item>
              <item>Sequence: 1, 2, repeat</item>
              <item>Sequence: 1, 3, 2, repeat</item>
              <item>Sequence: 1, 3, 2, 4, repeat</item>
            </comboBox>
            <checkBox id="pw.captions">Include Captions</checkBox>
            <checkBox id="pw.pageNums">Include Page Numbers</checkBox>
            <label id="pw.header.lbl">Header:</label>
            <lineEdit id="pw.header"></lineEdit>
            <label id="pw.footer.lbl">Footer:</label>
            <lineEdit id="pw.footer"></lineEdit>
          </panel>
        </group>
      </panel>
  </dialog>

  <dialog id="pw">
    <label id="pw.titleBar"></label>
      <panel id="pw.publish">
        <group id="pw.publish.frame">
          <panel id="pw.publish.group">
            <label id="pw.publish.lbl">Publish Options:</label>
            <button id="pw.publish.print">Print</button>
            <button id="pw.publish.email">E-mail</button>
          </panel>
        </group>
        <group id="pw.summmary.frame">
          <panel id="pw.summary.group">
            <label id="pw.projectName.lbl">Name:</label>
            <lineEdit id="pw.projectName"></lineEdit>
            <checkBox id="pw.usetitleforname.cb">Use Title for
Name</checkBox>
            <label id="pw.summary.lbl"></label>
            <label id="pw.graphic"></label>
          </panel>
        </group>
      </panel>
      <panel id="pw.template">
        <group id="pw.title.frame">
          <panel id="pw.title.group">
            <checkBox id="pw.title.cb"></checkBox>
            <label id="pw.title.lbl">Title:</label>
            <lineEdit id="pw.title"></lineEdit>
          </panel>
        </group>
        <group id="pw.pages.frame">
          <panel id="pw.pages.group">
            <label id="pw.pages.lbl">Photos Per Page:</label>
            <comboBox id="pw.pages">
              <item>1</item>
              <item>2</item>
              <item>3</item>
              <item>Sequence: 1, 2, repeat</item>
              <item>Sequence: 1, 3, 2, repeat</item>
            </comboBox>
            <checkBox id="pw.captions">Include Captions</checkBox>
          </panel>
        </group>
        <group id="pw.presentation.frame">
          <panel id="pw.presentation.group">
            <checkBox id="pw.repeat">Repeat Slideshow</checkBox>
            <checkBox id="pw.showControls">Include Play
Controls</checkBox>
            <checkBox id="pw.allowResize">Allow to Resize</checkBox>
            <label id="pw.transition.lbl">Transition:</label>
            <comboBox id="pw.transition">
              <item>None</item>
              <item>1</item>
              <item>2</item>
              <item>3</item>
              <item>4</item>
            </comboBox>
            <label id="pw.duration.lbl">Time</label>
            <comboBox id="pw.duration">
              <item>2 sec</item>
              <item>4 sec</item>
              <item>10 sec</item>
            </comboBox>
            <label id="pw.music.lbl">Background Music:</label>
            <comboBox id="pw.music">
              <item>None</item>
              <item>A_fool_and_the_thing_h.mp3</item>
            </comboBox>
            <button id="pw.music.browse">Browse</button>
            <checkBox id="pw.audioCaptions">Play Audio
Captions</checkBox>
          </panel>
        </group>
      </panel>
  </dialog>
  </main>






-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Joerg
Heinicke
Sent: Saturday, October 12, 2002 3:00 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Eliminating duplicate nodes

Hi Mac,

you must tell us, how you define "duplicate nodes". In your XML the 
following snippet is obviously duplicate:

      <panel id="selection">
        <label id="selection">Select the template type:</label>
        <button id="download">Download New Templates</button>
        <label id="detail"></label>
      </panel>

But what is when one of the text nodes is different or the button has 
another id, but the rest is the same? Tell us the rules for identity.

Another question is what you are doing with <xsl:call-template/>. This 
often breaks normal XML tree processing.

Did you have already a look at 
http://www.jenitennison.com/xslt/grouping/muenchian.xml? Can you post a 
bit of your non-working code?

Regards,

Joerg

Mac Martine wrote:

Hi-
 I am trying creating an HTML page from XML/XSL.
I want to eliminate duplicate nodes, and it seems like there are 2
ways
to do this: using variables, and using keys. But I haven't gotten
either
to work yet.
Could someone recommend which method would be better, and maybe help
get
me started on the right path?

Below is a little snippet of my xml:
I use <call-template> when I hit nodes of a certain name

Thanks-
 Mac

<desktop>
        <label id="titleBar"></label>
      <panel id="selection">
        <label id="selection">Select the template type:</label>
        <button id="download">Download New Templates</button>
        <label id="detail"></label>
      </panel>
      <panel id="style">
        <label id="style">Choose your Slideshow style:</label>
        <label id="preview"></label>
      </panel>

       <label id="titleBar"></label>
      <panel id="selection">
        <label id="selection">Select the template type:</label>
        <button id="download">Download New Templates</button>
        <label id="detail"></label>
      </panel>
      <panel id="style">
        <label id="style">Choose your Slideshow style:</label>
        <label id="preview"></label>
      </panel>
</desktop>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>