6 Replies Latest reply on Jun 10, 2013 2:46 PM by odaboval

    How to check external file (logo) existence?

    odaboval
      Hello all,

      We use BIP 11.1.1.6 (build 5.12.110)

      In our rtf template, we use external logo with command :
      <fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/>
      That works perfectly.

      But, we would like to check existence of the logo file before printing it, and if the logofile doesn't exist then display a default logo.

      Is it possible to check file existence in this situation ?

      Thanks in advance,
      Olivier
        • 1. Re: How to check external file (logo) existence?
          AlexAnd
          >
          But, we would like to check existence of the logo file before printing it, and if the logofile doesn't exist then display a default logo.

          Is it possible to check file existence in this situation ?
          >
          not sure that you can do it

          as idea
          as you have url of image in variable LOGOFILE you can re-assign it
          say in xml data
          ...
          <image>http://somelogourl</image>
          <defaultimage>http://somelogourl</defaultimage>
          ..
          if image tag has value when use it
          else image tag hasn't value when use defaultimage value
          ...
          <image></image>
          <defaultimage>http://somelogourl</defaultimage>
          ..
          so before insert logo check it like
          <?if:image!=''?>
          <?xdoxslt:set_variable($_XDOCTX,'LOGOFILE', image)?>
          <?end if?>
          <?if:image=''?>
          <?xdoxslt:set_variable($_XDOCTX,'LOGOFILE', defaultimage)?>
          <?end if?>
          <fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/>
          or by
          xdoxslt:ifelse
          1 person found this helpful
          • 2. Re: How to check external file (logo) existence?
            odaboval
            Hello AlexAnd,
            I tried to put together all what you said, but as soon as I used <image>, the engine sends this error below:

            Here is my code :
            <?xdoxslt:set_variable($_XDOCTX, 'OU', substring(IdReference/Description, 1, 4))?>
            OU:<?xdoxslt:get_variable($_XDOCTX, 'OU')?>
            <?xdoxslt:set_variable($_XDOCTX, 'LOGOFILE', concat( 'C:\GFS\images\', xdoxslt:get_variable($_XDOCTX, 'OU'),'.jpg'))?>
            LOGOFILE:<?xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')?>
            <?xdoxslt:set_variable($_XDOCTX, 'DEFAULTLOGO', concat( 'C:\GFS\images\', 'Default','.jpg'))?>
            DEFAULTLOGO:<?xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')?>
            <image><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/></image>
            <defaultimage><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')}')"/></defaultimage>
            The error comes before the 2 if commands.

            Here is the error detail:
            [052413_003637400][oracle.xdo.template.FOProcessor][EXCEPTION] oracle.xdo.XDOSAXException: org.xml.sax.SAXException: element image is not supported yet.
                 at oracle.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:421)
                 at oracle.xdo.template.FOProcessor.generate(FOProcessor.java:1218)
                 at RTF2PDF2.runRTFto(RTF2PDF2.java:473)
                 at RTF2PDF2.runXDO(RTF2PDF2.java:337)
                 at RTF2PDF2.main(RTF2PDF2.java:230)
            Caused by: org.xml.sax.SAXException: element image is not supported yet.
                 at oracle.xdo.template.fo.FOHandler.startElement(FOHandler.java:285)
                 at oracle.xdo.common.xml.XSLTHandler$SEEntry.sendEvent(XSLTHandler.java:542)
                 at oracle.xdo.common.xml.XSLTMerger.startElement(XSLTMerger.java:51)
                 at oracle.xdo11g.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:182)
                 at oracle.xdo11g.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1322)
                 at oracle.xdo11g.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:366)
                 at oracle.xdo11g.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:312)
                 at oracle.xdo11g.parser.v2.XMLParser.parse(XMLParser.java:218)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                 at java.lang.reflect.Method.invoke(Unknown Source)
                 at oracle.xdo.common.xml.XDOSAXParser.invokeParse(XDOSAXParser.java:166)
                 at oracle.xdo.common.xml.XDOSAXParser.parse(XDOSAXParser.java:122)
                 at oracle.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:407)
                 ... 4 more
            
            [052413_003637402][oracle.xdo.template.FOProcessor][ERROR] End Memory: max=227MB, total=98MB, free=47MB
            I may not clearly translate what you suggested, I think about the setting of <image> and <defaultimage> with command fo:external-graphic, but this came as an immediate thought.

            Any suggestion ?
            Can you help ?

            Thanks,
            Olivier
            • 3. Re: How to check external file (logo) existence?
              AlexAnd
              >
              <?xdoxslt:set_variable($_XDOCTX, 'OU', substring(IdReference/Description, 1, 4))?>
              OU:<?xdoxslt:get_variable($_XDOCTX, 'OU')?>
              <?xdoxslt:set_variable($_XDOCTX, 'LOGOFILE', concat( 'C:\GFS\images\', xdoxslt:get_variable($_XDOCTX, 'OU'),'.jpg'))?>
              LOGOFILE:<?xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')?>
              <?xdoxslt:set_variable($_XDOCTX, 'DEFAULTLOGO', concat( 'C:\GFS\images\', 'Default','.jpg'))?>
              DEFAULTLOGO:<?xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')?>
              <image><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/></image>
              <defaultimage><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')}')"/></defaultimage>
              >
              to
              <?xdoxslt:set_variable($_XDOCTX, 'OU', image)?>
              <?xdoxslt:set_variable($_XDOCTX, 'OU', xdoxslt:ifelse(xdoxslt:get_variable($_XDOCTX,'OU')='', defaultimage, image))?>
              <?xdoxslt:get_variable($_XDOCTX,'OU')?>
              
              <?xdoxslt:set_variable($_XDOCTX, 'LOGOFILE', concat( 'C:\tmp\image\', xdoxslt:get_variable($_XDOCTX, 'OU'),'.jpg'))?>
              so if "image" tag has value then it'll be used
              if "image" tag hasn't value then defaultimage will be used

              i tested and it's work for me
              1 person found this helpful
              • 4. Re: How to check external file (logo) existence?
                odaboval
                Hello AlexAnd,

                Thanks a lot for your quick answer. I really appreciate.

                I will try to implement your suggestion.

                The problem that I have is that, even if the filename is correctly built using the XML data, I am not able to know the existence of the file located on Unix.
                That's why I need to find a way for getting information from the file itself, and why I was thinking about testing the image size or file size.

                I'll write a reply later.
                and thanks again,
                Olivier
                • 5. Re: How to check external file (logo) existence?
                  gareth.roberts
                  Hi Olivier,

                  Just on the outside chance that is works - Could you put the default logo underneath (behind) the external logo in the layout, then if external logo doesn't exist you'll just "see" the default logo. I've done similar with Print vs Email bi publisher output in EBS.

                  Regards,
                  Gareth
                  http://garethroberts.blogspot.com
                  • 6. Re: How to check external file (logo) existence?
                    odaboval

                    Hello Gareth,

                     

                    Thansk a lot for the suggestion ...

                    But, In that case of an existing, it displays 2 logos ( the specific and the default logos).

                    Is there any other stuff to add in the code, in order to not display 2 logos ?

                     

                    Regards,

                    Olivier