1. alex co
  2. PowerBuilder
  3. Tuesday, 18 October 2022 19:59 PM UTC

I have a DW save to XML file then eventually to KML file (GOOGLE EARTH) project, where I need to append this predefined XML as a HEADER section (below is a small sample) to the top of the DW generated XML file.  how do I prevent Powerbuilder from converting ( <   to  < ) ( >  to > )  ( " to " )???? 

<name>Meters</name>
<Style id="BlueNormal">
<IconStyle>
<color>ffff0000</color>
<scale>0.6</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/triangle.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
<visibility>1</visibility>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
</Style>

so placed the lines above to a COMPUTED COLUMN  as TEXT in the DW, but it comes out as below when the DW is saved as XML file.

&lt;name&gt;Meters&lt;/name&gt;
&lt;Style id=&quot;BlueNormal&quot;&gt;
&lt;IconStyle&gt;
&lt;color&gt;ffff0000&lt;/color&gt;
&lt;scale&gt;0.6&lt;/scale&gt;
&lt;Icon&gt;
&lt;href&gt;http://maps.google.com/mapfiles/kml/shapes/triangle.png&lt;/href&gt;
&lt;/Icon&gt;
&lt;/IconStyle&gt;
&lt;LabelStyle&gt;
&lt;scale&gt;0&lt;/scale&gt;
&lt;/LabelStyle&gt;
&lt;visibility&gt;1&lt;/visibility&gt;
&lt;extrude&gt;1&lt;/extrude&gt;
&lt;altitudeMode&gt;relativeToGround&lt;/altitudeMode&gt;
&lt;/Style&gt;

I thought about using a COMPOSITE DW but i just realized the HEADER section is composed of two types of tags,  look at tags (Style id,  StyleMap id) in the attached XML file

and i am not sure how to formulate the Export /Import Template - XML for a COMPOSITE DW and would it work????

thank you 

Alex

Accepted Answer
alex co Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 22:24 PM UTC
  2. PowerBuilder
  3. # Permalink

Solution is to use the DW to generate the XML for all the natural gas meter data, latitude, longitude we need.  We used the DW because we have several criteria's, filters and sorting that the user can apply to the data prior to creating the XML.   After the creating the XML file since the users have to save it as KML we have a manual step to cut and paste all the XML formatted header section into the file.   The KML file successfully loaded and displayed in GOOGLE EARTH PRO.  Anyone can use the file below to plot anything in google earth after putting in your latitude and longitude, the file is a working sample.

below is the actual generated XML by the DW.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Document>
<name>CMS GAS METERS</name>
<!--BEGIN COPY STYLE HEADER SECTION HERE-->

<!--USER WILL MANUALLY CUT AND PASTE THE PREFORMATED XML HERE-->

<!--END COPY STYLE HEADER SECTION HERE-->

<Folder>

       <!--THIS SECTION CONTAINS THE XML METER DATA GENERATED BY THE DW -->

      <name>METER DISTRICT LOCATION</name> 
      <open>0</open>
      <Folder>
                     <name>CHECK</name>
                     <open>0</open>
                     <Placemark>
                               <name>
                                            <![CDATA[999999:METER NAME]]>
                               </name>
                               <description>
                                                  <![CDATA[Meter Number : 999999]]>
                                                  <![CDATA[Meter Name : A METER NAME>
                                                  <![CDATA[Analyst : JOHN SNOW]]>
                                                  <![CDATA[Supervisor : JOHN, DOE]]>
                                                  <![CDATA[Tech : JANE, DOE]]>
                                                  <![CDATA[Meter Status : Active]]>
                                                  <![CDATA[District : METER DISTRICT LOCATION]]>
                                                  <![CDATA[Meter Purpose :CHECK]]>
                                                  <![CDATA[Lateral Code : 9]]>
                              </description>
                              <styleUrl>
                                             <![CDATA[Blue3]]>
                              </styleUrl>
                              <Point>
                                             <coordinates>
                                                                <![CDATA[LONGITUDE, LATITUDE]]>
                                             </coordinates>
                              </Point>
                   </Placemark>

     </Folder>

</Folder>
</Document>


 

Comment
  1. René Ullrich
  2. Wednesday, 26 October 2022 05:12 AM UTC
You can put different datawindows in XML without Folders with a trick: Add a XML comment between the datawindows.

  1. Helpful
  1. alex co
  2. Wednesday, 26 October 2022 15:56 PM UTC
Adding XML comments between DW did not work. The XML Template editor did not allow me to add another DW control reference, that option is grayed out after you add your first DW control reference. please attach a screenshot of your export/import Template -XML window where you have done so.
  1. Helpful
  1. René Ullrich
  2. Thursday, 27 October 2022 04:53 AM UTC
Yes, you are right. The option is grayed out. I'm not sure but I think I've added it in exported source. And it works. I'll add a screenshot.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 27 October 2022 04:57 AM UTC
  2. PowerBuilder
  3. # 1

How to add multiple nested datawindows in a XML template without subfolders:

You can't do it in the painter but you can change it in dw source.

In exported source (shortened):

export.xml(... xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"no~"?><verwendungsnachweis><abrufPositions><!--Sachausgaben-->dw_abrufpos<!--Personalausgaben-->dw_personalausgaben<!--Standardeinheitskosten-->dw_standardeinheitskosten</abrufPositions></verwendungsnachweis>"))
Comment
  1. alex co
  2. Thursday, 27 October 2022 13:41 PM UTC
thank you, Rene this is very helpful to know. Maybe we should submit this as an enhancement request for the XML Template creation screen, since clearly you were able to bypass the restriction, but it still worked. Atttention Appeon PB engineering team please explain why you have the restriction, if it can be bypassed without error.

  1. Helpful
  1. René Ullrich
  2. Thursday, 27 October 2022 13:47 PM UTC
It can only work if you have some tags (in my example the comments) between the datawindows. If you have two datawindows directly side by side it doesn't work because there is no delimiter between the datawindows in this case the parser need to separate it. Maybe this is the reason for the restriction in the painter.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 15:29 PM UTC
  2. PowerBuilder
  3. # 2

[Edit: I didn't notice that Benjamin had already answered something similar to my reply.]

Hi,

How do you write the predefined header?

As far as I see it, to avoid having to replace anything, you could simply use:

- FileOpen , creating a new file,

- use FileWrite to write the predefined header

- export the data of your dw to xml

- use FileWrite or FileWriteEx to write the xml data

- FileClose

Maybe I'm missing something?

regards,

MiguelL

Comment
  1. alex co
  2. Friday, 21 October 2022 18:03 PM UTC
- export the data of your dw to xml

this step added another header line coming from the DW to XML export after the predefined header section





<Document>
  1. Helpful
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 10:11 AM UTC
  2. PowerBuilder
  3. # 3

Hi Alex,

if I'm understanding this correctly, you're generating an XML file and want to add these lines to the top of the generated file? In that case I would open the XML file using FileOpen(), alter the content accordingly and write it back. The DW->XML export is useful for exporting actual data as XML, not to write predefined XML code to a file.

Comment
  1. alex co
  2. Wednesday, 19 October 2022 13:31 PM UTC
Hello Benjamin,

You are correct I want to add/write these predefined XML code the top of the generated XML file like a HEADER, because it does not change. We need it on TOP HEADER before all the DETAIL records generated by the DW are written.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 18 October 2022 20:33 PM UTC
  2. PowerBuilder
  3. # 4

Hi Alex;
  The DWO is correct as it wants to write the HTML as per international standards and that would be to "escape" all the extended characters in the HTML data stream. That way, any standard wen browser will display these extended characters correctly no matter the O/S, language, code page, etc  the we browser is running under.
  In your special case though, you will need to use the PB "Replace" command to change the DWO's escaped HTML characters back to the way you need them after the SaveAs command.
Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 19 October 2022 20:23 PM UTC
Because the lower data has no "extended characters". That is, they are all printable ANSI characters from 32 to 127.

Whereas Extended characters are any character number > 127 (which should then be escaped), as follows...

https://www.ascii-code.com
  1. Helpful 1
  1. alex co
  2. Friday, 21 October 2022 17:43 PM UTC
Chris,



Replace command does not work in conjucton to FileOpen commands. I cannot use this approach.



Alex
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 21 October 2022 18:05 PM UTC
Correct as Replace is a PowerScript text manipulation command vs an external File processing command.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.