5 Replies Latest reply on Feb 4, 2015 2:41 AM by Loic.Aigon

    Problem with xsl?

    Stamm Level 1

      Hey guys,

       

      I am experiencing a strange problem with xsl:

       

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

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

         

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

           <xsl:copy> 

               <xsl:apply-templates select="@*|node()|*[not(self::table)]"/> 

           </xsl:copy> 

          </xsl:template> 

         

          <xsl:template match="@value"> 

           <xsl:attribute name="value"> 

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

           </xsl:attribute> 

          </xsl:template> 

         

          <xsl:template match="text">

              <xsl:copy>

                  <xsl:attribute name="value">

                      <xsl:apply-templates/>

                  </xsl:attribute>

              </xsl:copy>

          </xsl:template>

       

       

          <xsl:template match="b">

              <xsl:text>[b]</xsl:text>

                  <xsl:apply-templates/>

              <xsl:text>[/b]</xsl:text>

          </xsl:template>

       

       

          <xsl:template match="i">

              <xsl:text>[i]</xsl:text>

                  <xsl:apply-templates/>

              <xsl:text>[/i]</xsl:text>

          </xsl:template>

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

      </xsl:stylesheet> 

       

      My Xml looks like this:

      <medium>

           <sheets>

                <sheet>

                     <site>

                          All Elements

                     </site>

                </sheet>

           </sheets>

      </medium>

       

      A <text-area> tag will look like this:

      <text-area>

           <text>

                this is the <b>normal</b> indesign content

           </text>

      </text-area>.

       

      After xsl:

       

      <text-area>

           <text value="this is the [b]normal[/b] indesign content"/>

      </text-area>

       

      Now the Problem:

       

      When I export it in indesign and choose sheets, sheet, site or any other element where <text-area> is a child, it exports it as:


      <text-area>

           <text value="this is the [b]normal[/b] indesign content"/>


      </text-area>.


      ONLY when I choose medium it will look like this:


      <text-area>

           <text value="this is the normal indesign content">

                this is the <b>normal</b> indesign content

           </text>

      </text-area>

       

      Why is this happening? I have NO idea... Why is it working on every other element other than "medium"?

        • 1. Re: Problem with xsl?
          Stamm Level 1

          Does anyone have a thought on this? Any advice is highly appreciated!

          • 2. Re: Problem with xsl?
            Loic.Aigon Adobe Community Professional

            Hi Stamm,

             

            Could you share XML so we can have a closer look ?

             

            Loic

            • 3. Re: Problem with xsl?
              Stamm Level 1

              Hey, of course!

               

              <medium xmlns="example" xmlns:xsi="example" xsi:schemaLocation="example" name="Karte" description="asd" summary="asd" id="Karte_3/11/2015/16">

                <thumbnail src="http://karte/thumb.png"/>

                <sales-plan>

                  <download price="3"/>

                </sales-plan>

                <sheets>

                  <sheet>

                    <site width="216.0" height="111.0" trim="3">

                      <text-area x="116.00000007" y="32.10000002" width="88.00" height="51.60" line-height="8.4666666720" readonly="true" text-align="left" orientation="0">

                        <text value="Ein herzlich frohes Weihnachtsfest, viel Freude, Glück und Gesundheit für das Neue Jahr.">

                          <b>Ein herzlich frohes Weihnachtsfest, viel Freude, Glück und Gesundheit für das Neue Jahr.</b>

                        </text>

                        <font size="7.0555555600"/>

                        <foreground-color c="0" m="0" y="0" k="0"/>

                      </text-area>

                      <graphic-area x="-0.00000000" y="98.30000006" width="216.00" height="12.70" orientation="0">

                        <foreground-color-ref idref="user-color"/>

                        <svg>

                          <g class="user-color" style="fill:[user-color];">

                            <rect x="0" y="0" width="100%" height="100%" style="fill:[user-color];"/>

                            <rect x="0" y="0" width="100%" height="100%" fill=" #000" style="fill-opacity:0"/>

                          </g>

                        </svg>

                      </graphic-area>

                      <text-area x="10.20000000" y="102.00416673" width="202.800000" height="5.995833" line-height="4.2333333360" readonly="true" text-align="left" orientation="0">

                        <text value="[user-firmname] · [user-firstname] [user-lastname] · [user-street] [user-housenr] · [user-zipcode] [user-city]">Firmenname · Ansprechpartner · Straße H.Nr. · PLZ · Ort</text>

                        <font size="3.5277777800" weight="normal"/>

                        <foreground-color c="0" m="0" y="0" k="0"/>

                      </text-area>

                    </site>

                  </sheet>

                </sheets>

              </medium>

               

              As you can see, text-area looks quite strange. It should be:

              <text-area x="116.00000007" y="32.10000002" width="88.00" height="51.60" line-height="8.4666666720" readonly="true" text-align="left" orientation="0">

                        <text value="[b]Ein herzlich frohes Weihnachtsfest, viel Freude, Glück und Gesundheit für das Neue Jahr.[/b]" />

                        <font size="7.0555555600"/>

                        <foreground-color c="0" m="0" y="0" k="0"/>

              </text-area>

              • 4. Re: Problem with xsl?
                Stamm Level 1

                The solution, credits to the author( xml - Xsl transforms correctly choosing children but not on ancestor in indesign? - Stack Overflow ):

                 

                <?xml version="1.0" encoding="UTF-8" ?>
                <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
                  
                <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

                  
                <xsl:template match="@*|node()">
                  
                <xsl:copy>
                  
                <xsl:apply-templates select="@*|node()|*[not(self::table)]"/>
                  
                </xsl:copy>
                  
                </xsl:template>

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

                  
                <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="@href"/>

                </xsl:transform>

                • 5. Re: Problem with xsl?
                  Loic.Aigon Adobe Community Professional

                  Thanks for sharing the solution here