Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Custom XML output

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Custom XML output
 Login/Join
 
Member
posted
I am trying to populate a JQuery script using xml output from a fex. The output needs to look like this:

<?xml version="1.0" encoding="utf-8" ?> 
- <navigation>
- <navItem title="ENGLAND">
  <subNavItem url="JAGUAR.html" title="JAGUAR" /> 
  <subNavItem url="JENSEN.html" title="JENSEN" /> 
  <subNavItem url="TRIUMPH.html" title="TRIUMPH" /> 
  </navItem>
- <navItem title="JAPAN">
  <subNavItem url="DATSUN.html" title="DATSUN" /> 
  <subNavItem url="TOYOTA.html" title="TOYOTA" /> 
  </navItem>
- <navItem title="ITALY">
  <subNavItem url="ALPHA_ROMEO.html" title="ALPHA ROMEO" /> 
  <subNavItem url="MASERATI.html" title="MASERATI" /> 
  </navItem>
  </navigation>  


Any ideas? This needs to be called by the HTML page and return as XML data.

Thanks,
-Troy

This message has been edited. Last edited by: Kerry,


WF version 8105
all output
 
Posts: 28 | Registered: February 17, 2010Report This Post
Platinum Member
posted Hide Post
How were you going to get output produced from a fex? Whenever I create custom XML with WebFOCUS I have to use WRITE commands to create a file and then read it in via javascript.

Lately, I've been using JQuery to read WebFOCUS formatted XML output that is returned using the command: ON TABLE PCHOLD FORMAT XML


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
<FreSte>
posted
I think it can be done using ON TABLE HOLD FORMAT WP


-Fred-

DEFINE FILE CAR
  LINE1/A50 = '<navItem title="' || COUNTRY || '"> ';
  LINE2/A80 = '<subNavItem url="' || CAR || '.HTML" title="' || CAR || '" />';
  LINE3/A20 = '</navItem>';
END

TABLE FILE CAR
  BY COUNTRY NOPRINT
  BY LINE2 AS ''
  ON COUNTRY SUBHEAD
  "<LINE1"
  ON COUNTRY SUBFOOT
  "<LINE3"
  ON TABLE HOLD AS RPRT FORMAT WP
  ON TABLE SET PAGE NOPAGE
END
-RUN


SET HTMLFORMTYPE=TXT
-HTMLFORM BEGIN
<?xml version="1.0" encoding="utf-8" ?>
<navigation>
  !IBI.FIL.RPRT;
</navigation>
-HTMLFORM END
-EXIT
 
Report This Post
Member
posted Hide Post
That is perfect FreSte. Thanks so much


WF version 8105
all output
 
Posts: 28 | Registered: February 17, 2010Report This Post
Virtuoso
posted Hide Post
An alternative (this might only be available in 77 however):

Master:
FILENAME=WSDEMO_XMLTEST, SUFFIX=XML     ,
 DATASET=wsdemo/xmltest.xml, $
  SEGMENT=NAVIGATION, SEGTYPE=S0, $
    FIELDNAME=NAVIGATION, ALIAS=navigation, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL), $
  SEGMENT=NAVITEM, SEGTYPE=S0, PARENT=NAVIGATION, $
    FIELDNAME=NAVITEM, ALIAS=navItem, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL),
      REFERENCE=NAVIGATION, PROPERTY=ELEMENT,  $
    FIELDNAME=TITLE, ALIAS=title, USAGE=A70, ACTUAL=A70,
      REFERENCE=NAVITEM, PROPERTY=ATTRIBUTE,  $
  SEGMENT=SUBNAVITEM, SEGTYPE=S0, PARENT=NAVITEM, $
    FIELDNAME=SUBNAVITEM, ALIAS=subNavItem, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL),
      REFERENCE=NAVITEM, PROPERTY=ELEMENT,  $
    FIELDNAME=SUBURL, ALIAS=url, USAGE=A70, ACTUAL=A70,
      REFERENCE=SUBNAVITEM, PROPERTY=ATTRIBUTE,  $
    FIELDNAME=SUBTITLE, ALIAS=title, USAGE=A70, ACTUAL=A70,
      REFERENCE=SUBNAVITEM, PROPERTY=ATTRIBUTE,  $
  


Fex to build xml:
-*new file
TABLE FILE ibisamp/CAR
PRINT 
COMPUTE TITLE/A70= COUNTRY;
COMPUTE SUBURL/A70= CAR || '.htm';
COMPUTE SUBTITLE/A70= CAR;
BY COUNTRY NOPRINT
ON TABLE HOLD AS TEST FORMAT ALPHA
ON TABLE SET HOLDLIST PRINTONLY
END
-RUN
 
CREATE FILE XMLTEST DROP 
MODIFY FILE XMLTEST
MATCH TITLE
ON MATCH CONTINUE
ON NOMATCH INCLUDE
MATCH SUBURL
ON MATCH INCLUDE
ON NOMATCH INCLUDE
FIXFORM FROM TEST
DATA ON TEST
END
-RUN
 
EX EDAGET XML,wsdemo/xmltest,T
-RUN
  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Guru
posted Hide Post
Support for XML output is built in to DataMigrator and requires no coding. From the DMC create a synonym, say NAVIGATION, for the xml checking "Make Unique" so that the second TITLE element gets named TITLE1. In the synonym editor change the length of the fields from the default A10 to A16 for TITLE1 and A21 for URL.

Then create a data flow with CAR as source and NAVIGATION as target. In SQL select CAR and COUNTRY. In the target transformations map
TITLE = COUNTRY
URL = CAR||'.html'
TITLE1 = CAR
Submit and you are done.


N/A
 
Posts: 397 | Location: New York City | Registered: May 03, 2007Report This Post
Virtuoso
posted Hide Post
Nicely put!


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Platinum Member
posted Hide Post
@FreSte - that's pretty slick. I'm gonna use that coding technique. Thanks.


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
You can't call DataMigrator to populate a JQuery script that's in an HTML page.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
So if I wanted to call this fex (with xml output) from a Jquery script, does anyone have a sample of how it would work (from an HTML page)?


WF version 8105
all output
 
Posts: 28 | Registered: February 17, 2010Report This Post
<FreSte>
posted
Troy,

Below an example how to do it.
I saved the fex (see my post above) as cardata_as_xml.fex in my baseapp folder and
the code below was also saved in baseapp as xml_jquery.htm

And url is: http://localhost:8080/approot/baseapp/xml_jquery.htm

Cheers,

-Fred-



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <title>Demo jQuery / WebFOCUS</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

    <style>
    body {
        font-family:verdana;
        font-size:14px;
    }
    .data {
        padding:20px;
    }
    .navItem {
        color   : navy;
        font-size:18px;
    }

    .subNavItem {
        padding-left:20px;
    }
    </style>

    <script>
    var glbWebFocusUrl = "http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=cardata_as_xml";

    function getXmlData() {
        $.ajax({
            type    : "GET",
            url     : glbWebFocusUrl,
            dataType: "xml",
            success : function(_data) {
                $("#content").empty();
                $(_data).find("navItem").each(function() {
                    var html = "";
                    var $navItem = $(this);
                    html += "<div class='data'>";
                    html +=   "<div class='navItem'>" + $navItem.attr("title") + "</div>";

                    var $subNavItem = $navItem.find('subNavItem');
                    $subNavItem.each(function() {
                        html += "<div class='subNavItem'>" + $(this).attr("url") + " (---" + $(this).attr("title").toLowerCase() + "---)</div>";
                    })

                    html += "</div>";
                    $("#content").append(html);
                });
            }
        });
    }
    </script>
</head>

<body id="body">
  <button onclick=getXmlData()>getXMLData</button>
  <div id="content">
  </div>
</body>
</html>

This message has been edited. Last edited by: <FreSte>,
 
Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Custom XML output

Copyright © 1996-2020 Information Builders