4 Replies Latest reply on Jul 8, 2014 8:04 AM by Pelter

    Asign paragraph styles to xml nodes

    fruitsalad

      Hello all,

       

      I try to asign paragraph styles to xml nodes. I tried to autoasign the styles to tags and also to assign the styles directly to the xml tags with aid:pstyle. None of it with success. I think that this happens because there is a paragraph formating missing in my xml. I tried to change this with <aid:br/> but also no success.

       

      This is how my xsl looks like:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
        <xsl:output method = "xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:strip-space elements="*"/>
        <xsl:template match="ooo_sheet">
          <Root>
            <xsl:for-each select="ooo_row">
                <Artikel>
                <xsl:copy-of select="Artikelnummer"/> 
                    <Bild>
                          <xsl:attribute name="href">
                        <xsl:text>file:///</xsl:text>
                        <xsl:value-of select="Bildpfad"/>
                          </xsl:attribute>
                    </Bild> 
                    <Text xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
                          <EK aid5:pstyle="EK"><xsl:value-of select="EK"/><aid:br/></EK>
                      <Details aid5:pstyle="Details"><xsl:value-of select="Details"/><aid:br/></Details>
                      <Abmessungen aid5:pstyle="Abmessungen"><xsl:value-of select="Abmessungen"/><aid:br/></Abmessungen>
                      <Artikelnummer aid5:pstyle="Artikelnummer"><xsl:value-of select="Artikelnummer"/><aid:br/></Artikelnummer>
                    </Text>
                </Artikel>
            </xsl:for-each>
          </Root>
        </xsl:template>
      </xsl:stylesheet>
      

       

       

      I want to achieve that I can pull the the following tag from the structure view in Indesign to a textframe and the text gets the different formating.

       

      <Text xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
                          <EK aid5:pstyle="EK"><xsl:value-of select="EK"/><aid:br/></EK>
                      <Details aid5:pstyle="Details"><xsl:value-of select="Details"/><aid:br/></Details>
                      <Abmessungen aid5:pstyle="Abmessungen"><xsl:value-of select="Abmessungen"/><aid:br/></Abmessungen>
                      <Artikelnummer aid5:pstyle="Artikelnummer"><xsl:value-of select="Artikelnummer"/><aid:br/></Artikelnummer>
      </Text>
      

       

       

      Could anyone point me to the right direction? Any help is very welcome. Thank you for your help.

        • 1. Re: Asign paragraph styles to xml nodes
          MW Design Level 4

          Without testing what you have in your post, some thoughts.

           

          One issue I see above is that this string, <xsl:value-of select=, shouldn't be in the XML. But also the styles that are referenced look a bit malformed.

           

          I would recommend simply typing in some text, assigning the paragraph styles to it, then export that as an XML file. Now, ID's XML export is pretty ugly and you will need to format it a bit to make clear sense of it. But of note is how the styes are formed in relation to the text part of the XML. Then make changes to your XSL to comply to that format.

           

          At its most basic, XML, when being treated basically as a raw text file, needs no formatting codes in it. So without really seeing a sample of valid XML it is hard to advise.

           

          My typical work-flow is XML that is sent to me as a raw UTF-8 or -16 file. If I need to manipulate it, I do so in either an XML editor or text editor capable of handling the needed UTF.

           

          A sample of that XML is brought in, I create needed paragraph and character styles which I usually name the same as the XML elements they will be assigned to. Which makes assigning the styles to the element tags a simple thing.

           

          If the XML is a large file, I will typically make a smaller version to deal with as I test an import or two. Work out any wrinkles or unforeseen formatting issues, etc.

           

          Mike

          • 2. Re: Asign paragraph styles to xml nodes
            fruitsalad Level 1

            Sorry, my last example was the xsl instead of the xml. Here is the xml I got. I want to pull the Root/Artikel/Text Tag to a frame and all Child tags within should be formated with the corresponding pstyles.

             

            But it looks like as if Indesign just does not tranform the aid5 style upon xml/xlst import. The <aid:br> tags you see are just a try of myself to get the tags within the Text tag separated as paragraph.

             

            But Indesign just interprets them as normal tags and also shows them in the structure pane.

             

             

            Thank you very much for your help. I also tried to format the text with the paragraph styles by hand and export the whole thing as xml from Indesign. But Indesign just the xml the same way I imported it. The same happens when I manually create a xml structure in Indesign, assign the styles to the text within the frame. Indesign just exports the raw xml structure. But no style declarations. So I can't see how to format the tags the right way.

             

            This is how my xml looks like when I import it with the upper xsl.

             

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <Root>
                <Artikel>
                    <Artikelnummer>C12-34567</Artikelnummer>
                    <Bild href="file:///Users/Diamondgroup/Desktop/KatalogBeispiel/cmyk/C12-34567.PSD"></Bild>
                    <Text xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
                        <EK aid5:pstyle="EK">1234,-<aid:br></aid:br></EK>
                        <Details aid5:pstyle="Details">AAA AAA AAA AAA<aid:br></aid:br></Details>
                        <Abmessungen aid5:pstyle="Abmessungen"><aid:br></aid:br></Abmessungen>
                        <Artikelnummer aid5:pstyle="Artikelnummer">C12-34567<aid:br></aid:br></Artikelnummer>
                    </Text>
                </Artikel>
                <Artikel>
                    <Artikelnummer>C23-45678</Artikelnummer>
                    <Bild href="file:///Users/Diamondgroup/Desktop/KatalogBeispiel/cmyk/C23-45678.PSD"></Bild>
                    <Text xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
                        <EK aid5:pstyle="EK">2345,-<aid:br></aid:br></EK>
                        <Details aid5:pstyle="Details">BBB BBB BBB BBB<aid:br></aid:br></Details>
                        <Abmessungen aid5:pstyle="Abmessungen"><aid:br></aid:br></Abmessungen>
                        <Artikelnummer aid5:pstyle="Artikelnummer">C23-45678<aid:br></aid:br></Artikelnummer>
                    </Text>
                 </Artikel>
            </Root>
            

             

             

            All the xsl: transformations work but the aid: and aid5: transformations just show in the xml as they where in the xsl.

            • 3. Re: Asign paragraph styles to xml nodes
              fruitsalad Level 1

              Ok, I managed to address the my style to the different tags. But although the Paragraph Styles exist in my Indesign document. The Text inside my tags does not get formated. When I select the Text it just doesnt have the paragraph styles.

               

              This is the xml that I import. Do I have to use a special namespace or aid: for Indesign CS6?

               

              <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
              <Root xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
                  <Artikel>
                      <Artikelnummer>C12-34567</Artikelnummer>
                      <Bild href="file:///Users/Diamondgroup/Desktop/KatalogBeispiel/cmyk/C12-34567.PSD"></Bild>
                      <Text>
                          <EK aid:pstyle="EK">1234,-</EK>
                          <Details aid:pstyle="Details">AAA AAA AAA AAA</Details>
                          <Abmessungen aid:pstyle="Abmessungen"></Abmessungen>
                          <Artikelnummer aid:pstyle="Artikelnummer">C12-34567</Artikelnummer>
                      </Text>
                  </Artikel>
                  <Artikel>
                      <Artikelnummer>C23-45678</Artikelnummer>
                      <Bild href="file:///Users/Diamondgroup/Desktop/KatalogBeispiel/cmyk/C23-45678.PSD"></Bild>
                      <Text>
                          <EK aid:pstyle="EK">2345,-</EK>
                          <Details aid:pstyle="Details">BBB BBB BBB BBB</Details>
                          <Abmessungen aid:pstyle="Abmessungen"></Abmessungen>
                          <Artikelnummer aid:pstyle="Artikelnummer">C23-45678</Artikelnummer>
                      </Text>
                  </Artikel>
                  <Artikel>
                      <Artikelnummer>C34-56789</Artikelnummer>
                      <Bild href="file:///Users/Diamondgroup/Desktop/KatalogBeispiel/cmyk/C34-56789.PSD"></Bild>
                      <Text>
                          <EK aid:pstyle="EK">3456,-</EK>
                          <Details aid:pstyle="Details">CCC CCC CCC CCC</Details>
                          <Abmessungen aid:pstyle="Abmessungen"></Abmessungen>
                          <Artikelnummer aid:pstyle="Artikelnummer">C34-56789</Artikelnummer>
                      </Text>
                  </Artikel>
              </Root>
              
              • 4. Re: Asign paragraph styles to xml nodes
                Pelter Level 1

                <Text aid:pstyle="Tekst">  works