This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: add elements


Naraschewski, E. wrote:
> First of all thank you very much for your answer!!!!!!!!!!
> 
> It nearly works now. The only problem left is, in my result file, the entries double. 

Sorry about that. You said your XML was like this

<entry>
  <MAT matid="687714453w">
    <Sachgebiete></Sachgebiete>
    <Fundstelle>
      <Band>1</Band>
      <Lektion>1</Lektion>
      <LektionsKategorie>X</LektionsKategorie>
      <AbsolutePos>1</AbsolutePos>
      <IndividPos>10816</IndividPos>
      <UbNummer>1</UbNummer>
    </Fundstelle>
  </MAT>
  <LO></LO>
</entry>

and you wanted to wrap the contents of 'entry' in a 'texteintrag' (as the only
child of 'entry') if the entry does not contain an 'UbNummer', right?

I misunderstood the format of your input and output (I thought you wanted the
'LO' to be outside of the 'texteintrag'), and I obviously gave you the wrong
answer anyway! I should have said this:

<?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" indent="no"/>

  <!-- identity transform for all nodes -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- non-UbNummer entries get a texteintrag content wrapper -->
  <xsl:template match="entry[not(MAT/Fundstelle/UbNummer)]">
    <xsl:copy>  <!-- or just <entry> -->
      <texteintrag>
        <xsl:apply-templates/>
      </texteintrag>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]