0 Replies Latest reply on Feb 11, 2015 3:04 AM by Stamm

    Linebreak in Indesign xsl?

    Stamm Level 1

      Hey guys,

       

      I have a little question about xsl. I tried to solve it myself, but I can't get it done.

       

      My xsl looks like this:

       

      <?xml version="1.0" encoding="UTF-8" ?>

      <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"

      xmlns:ex="example">

          <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

         

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

              <xsl:copy>

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

              </xsl:copy>

          </xsl:template>

         

          <xsl:template match="*[local-name() = 'table']"/>

        

          <xsl:template match="*[local-name() = 'text']">

              <xsl:copy>

                  <xsl:attribute name="value">

                      <xsl:apply-templates/>

                  </xsl:attribute>

              </xsl:copy>

          </xsl:template>

          

          <xsl:template match="*[local-name() = 'b' or local-name() = 'i']">

              <xsl:value-of select="concat('[',local-name(),']')"/>

                  <xsl:apply-templates/>

              <xsl:value-of select="concat('[/',local-name(),']')"/>

          </xsl:template>

         

          <xsl:template match="@value">

               <xsl:attribute name="value">

                   <xsl:value-of select="translate(.,'&#xd;','&#xa;')"/>

               </xsl:attribute>

          </xsl:template>

       

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

      </xsl:transform>

       

       

      What I found out, is that I could use something like this:

       

      <xsl:if test="not(position()=last())">

          <xsl:text>&#xA;</xsl:text>

      </xsl:if>

       

      But I don't know how to combine it with my xsl. I tried to just put it in the "<xsl:attribute name="value">" xsl:copy part. It inserts a linebreak, but at the wrong place. Also I cant put it inside of "xsl:apply-templates".

       

      Would someone be so kind to tell me, where I have to add this code?

       

      A xml example(how it looks originally, without any transforms):

      <text>This is some text and here

      is a linebreak</text>

       

      Should look like:

      <text value="This is some text and here&#xA;is a linebreak"/>

       

      Currently looks like:

      <text value="This is some text and here

      is a linebreak"/>

       

      Thank you in advance!