XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Hans LutschSubject: Mapping - How Include the Schema info at top of file.
Author: Hans Lutsch
Date: 13 Mar 2007 10:45 AM
Hi,
Total Newbie requires assitance :-)
I am using Mapper to transform a set of XML data to a specific published Schema for Reliability data. The end result is supposed to have a specific first few lines that indicate version, schema etc. I can get my whole map to work out but can't figure out how to get the first few lines to create without manualy pasting in the text after the XML file has been created. I would think that the Xquery could be made to do it for me but can't figure it out. My created file starts with " <ScheduledMaintenance><HDR_Segment> "

Apparently the top few lines of the created XML file should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<ScheduledMaintenance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScheduledMaintenance.xsd" Version="1.0">


The X querry at present looks like this:
I will also attach the Schema file

<ScheduledMaintenance>
<HDR_Segment>
<CHG>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/CHG/text()}
</CHG>
<ROC>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/ROC/text()}
</ROC>
<RDT>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/RDT/text()}
</RDT>
<RSD>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/RSD/text()}
</RSD>
<OPR>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/OPR/text()}
</OPR>
<RON>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/RON/text()}
</RON>
<WHO>
{doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/HDR%20SEGMENT1.xml')/dataroot/HDR_x0020_SEGMENT/WHO/text()}
</WHO>
</HDR_Segment>
{
for $_x0033__x0020_WPI_x0020_Table in doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/WPI_Compiler.xml')/dataroot/_x0033__x0020_WPI_x0020_Table
order by $_x0033__x0020_WPI_x0020_Table/ac
return
<ScheduledMaintenanceEvents>
<AID_Segment>
<MFR>
{$_x0033__x0020_WPI_x0020_Table/MFR/text()}
</MFR>
<AMC>
{$_x0033__x0020_WPI_x0020_Table/AMC/text()}
{$_x0033__x0020_WPI_x0020_Table/Model/text()}
</AMC>
<AIN>
{$_x0033__x0020_WPI_x0020_Table/APMfgSerNo/text()}
</AIN>
<REG>
{$_x0033__x0020_WPI_x0020_Table/REG/text()}
{$_x0033__x0020_WPI_x0020_Table/RegistrationNo/text()}
</REG>
<MFN>
{$_x0033__x0020_WPI_x0020_Table/MFN/text()}
</MFN>
<ASE>
{$_x0033__x0020_WPI_x0020_Table/Series/text()}
</ASE>
<OIN>
{$_x0033__x0020_WPI_x0020_Table/ac/text()}
</OIN>
</AID_Segment>
<WorkPackageDetails>
<WPI_Segment>
<WON>
{$_x0033__x0020_WPI_x0020_Table/wo/text()}
</WON>
<WOD>
{$_x0033__x0020_WPI_x0020_Table/StartDate/text()}
</WOD>
<WOE>
{$_x0033__x0020_WPI_x0020_Table/WOEndDate/text()}
</WOE>
<WOT>
{$_x0033__x0020_WPI_x0020_Table/wo_description/text()}
</WOT>
<MCI>
{$_x0033__x0020_WPI_x0020_Table/EO/text()}
</MCI>
<CTH>
{$_x0033__x0020_WPI_x0020_Table/MaxOfTOTAL_AC_FLIGHT_HOURS/text()}
</CTH>
<CTY>
{$_x0033__x0020_WPI_x0020_Table/MaxOftotal_ac_cycles/text()}
</CTY>
<OTT>
{$_x0033__x0020_WPI_x0020_Table/HOURS_RESET/text()}
</OTT>
<OPC>
{$_x0033__x0020_WPI_x0020_Table/CYCLES_RESET/text()}
</OPC>
</WPI_Segment>
<ScheduledMaintenanceDetails>
{
for $TASK_CARDS in doc('file:///c:/Documents%20and%20Settings/hlutsch/My%20Documents/WO%20TC.xml')/dataroot/TASK_CARDS
where $_x0033__x0020_WPI_x0020_Table/wo = $TASK_CARDS/WO
order by $TASK_CARDS/TASK_CARD
return
<HCD_Segment>
<HRI>
{$TASK_CARDS/WO_x0020_TC_x0020_KEY/text()}
</HRI>
<OST>
{$TASK_CARDS/OST/text()}
</OST>
<TED>
{$TASK_CARDS/TED/text()}
</TED>
<MIR>
{$TASK_CARDS/MIR/text()}
</MIR>
<COL>
{$TASK_CARDS/COL_x0020_CORLEVEL/text()}
</COL>
<COT>
{$TASK_CARDS/COT/text()}
</COT>
<COV>
{$TASK_CARDS/COV/text()}
</COV>
<TCD>
{$TASK_CARDS/TASK_CARD_DESCRIPTION/text()}
</TCD>
<ATA>
{$TASK_CARDS/ATATC/text()}
</ATA>
<OTI>
{$TASK_CARDS/TASK_CARD/text()}
</OTI>
<OTD/>
<TSK>
{$TASK_CARDS/TSK/text()}
</TSK>
<APD/>
<FDT>
{$TASK_CARDS/FDT/text()}
</FDT>
<DTA>
{$TASK_CARDS/ATA_x0020_NR/text()}
</DTA>
<MNT>
{$TASK_CARDS/MNT/text()}
</MNT>
<TSI>
{$TASK_CARDS/TSI/text()}
</TSI>
</HCD_Segment>
}
<EID_Segment>
<AET>
{$_x0033__x0020_WPI_x0020_Table/AET/text()}
</AET>
<EPC>
{$_x0033__x0020_WPI_x0020_Table/INSTALLED_POSITION/text()}
</EPC>
<EMS>
{$_x0033__x0020_WPI_x0020_Table/FIND_CHECKS2nd_PN_SN/text()}
</EMS>
<AEM>
{$_x0033__x0020_WPI_x0020_Table/FIND_CHECKS2nd_PN/text()}
</AEM>
<MFR>
{$_x0033__x0020_WPI_x0020_Table/MFR_x0020_ENG/text()}
</MFR>
</EID_Segment>
</ScheduledMaintenanceDetails>
</WorkPackageDetails>
</ScheduledMaintenanceEvents>
}
</ScheduledMaintenance>


The produced file should look like this: except I have not ALL of the elements in this sample included in my creation as many of them are not mandatory elements.

Sample

<?xml version="1.0" encoding="UTF-8"?>
<ScheduledMaintenance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScheduledMaintenance.xsd" Version="1.0">
<HDR_Segment>
<CHG>N</CHG>
<ROC>UAL</ROC>
<OPR>UAL</OPR>
<RDT>2001-07-01</RDT>
<RSD>2001-07-31</RSD>
<RON>United Airlines</RON>
<WHO>United Airlines</WHO>
</HDR_Segment>
<ScheduledMaintenanceEvents>
<AID_Segment>
<MFR>S4956</MFR>
<AMC>757</AMC>
<AIN>25398</AIN>
<REG>N550UA</REG>
<MFN>EMBRAER</MFN>
<ASE>200</ASE>
<OIN>550</OIN>
</AID_Segment>
<WorkPackageDetails>
<WPI_Segment>
<WON>123-4</WON>
<WOD>2003-10-22</WOD>
<WOE>2003-10-29</WOE>
<WDT>C-Check</WDT>
<MCI>MAINTENANCE BLOCK</MCI>
<MCV>4000 FH</MCV>
<CTH>10015.00</CTH>
<CTY>5025</CTY>
<OTT>3780.00</OTT>
<MAK>11</MAK>
<MAH>110.00</MAH>
<MAE>10.00</MAE>
<MMC>35000.00</MMC>
<MMT>75000.00</MMT>
<ICR>USD</ICR>
</WPI_Segment>
<ScheduledMaintenanceDetails>
<HCD_Segment>
<HRI>WO0305010003</HRI>
<OST>0</OST>
<TED>2002-08-10</TED>
<MIR>1</MIR>
<COL>2</COL>
<COT>Y</COT>
<COV>Y</COV>
<MII>27-188-00</MII>
<MRB>27-188</MRB>
<TCD>Functionally check hydraulic systems A, B and stand-by for internal leakage.</TCD>
<MTI>27-188-00-00</MTI>
<MTD>Speedbrake RTO System</MTD>
<OII>27-001a</OII>
<MCI>MAINTENANCE BLOCK</MCI>
<MCV>4000FH</MCV>
<OMN>300CY</OMN>
<CTH>10015.00</CTH>
<CTY>5025</CTY>
<OTT>3780.00</OTT>
<TSK>GVI</TSK>
<IMD>General Visual Inspection</IMD>
<SKL>EL</SKL>
<ICR>USD</ICR>
<APF>CK</APF>
<APD>Crack</APD>
<FDT>Bracket cracked FR 14 y 765 r/h. Fwd cabin floor Structure. Floor fitting. Fwd. Cabin floor Structure r/h dummy rail corroded FR 12-16.</FDT>
<NTC>COA27-55</NTC>
<NTD>One time inspection of hydraulic brake fuse for abnormal bypass</NTD>
<MNT>Replaced (with sometime indication of the replaced part); Repaired (by SRM XX.XX.XX/RAS XXXXX/SB XX.XXXX.) Oversized (to eliminate a crack indication in a hole)</MNT>
<TSI>1</TSI>
<MOT>One time inspection of hydraulic brake fuse for abnormal bypass. While performing task found a cut tire.</MOT>
<COR>CG</COR>
<COD>Galvanic; Stress; Exfoliation</COD>
<RAP>Repair According to SRM (Structural Repair Manual) and exceeded ADL (Allowable Damage Limit)</RAP>
<ALR>RH</ALR>
<ASP>Body Station</ASP>
</HCD_Segment>
<CMR_Segment>
<CMN>29-CMR-02</CMN>
<CMD>Sample description</CMD>
<CMP>1</CMP>
</CMR_Segment>
<LNK_Segment>
<OEI>F1002539820020101</OEI>
<MTN>403037279B33581</MTN>
</LNK_Segment>
<PAR_Segment>
<RED>2002-01-01</RED>
<MFR>12345</MFR>
<MPN>99999-2</MPN>
<SER>SN123-987</SER>
</PAR_Segment>
<MCI_Segment>
<MAH>110.00</MAH>
<MAK>11.00</MAK>
<MAE>10.00</MAE>
<MMC>35000.00</MMC>
<MMT>75000.00</MMT>
<ICR>USD</ICR>
</MCI_Segment>
<EID_Segment>
<AET>PW4000</AET>
<EPC>2</EPC>
<EMS>PCE-FA0006</EMS>
<AEM>PW4056</AEM>
<MFR>77445</MFR>
</EID_Segment>
<API_Segment>
<AET>331-400B</AET>
<EMS>SP-E994180</EMS>
<AEM>3800608-2</AEM>
<MFR>99193</MFR>
</API_Segment>
</ScheduledMaintenanceDetails>
</WorkPackageDetails>
</ScheduledMaintenanceEvents>
</ScheduledMaintenance>


UnknownScheduledMaintenance.xsd
Schema ATA SPEC2000 ScheduledMaintenance

Postnext
Alberto MassariSubject: Mapping - How Include the Schema info at top of file.
Author: Alberto Massari
Date: 15 Mar 2007 05:42 AM
Hi Hans,
you can add the three missing attributes by right clicking on the ScheduledMaintenance node in the target schema tree and selecting "Add Attribute"; then, you can assign a fixed value to it by right clicking on the attribute and selecting "Set Text Value"

Hope this helps,
Alberto

Postnext
Hans LutschSubject: Mapping - How Include the Schema info at top of file.
Author: Hans Lutsch
Date: 15 Mar 2007 10:28 AM
OH Excellent thats a big help! However it only addresses half the problem.

I got it to produce the second line like so:

<ScheduledMaintenance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScheduledMaintenance.xsd" Version="1.0">

But it still does not produce the first Declaration Line like this:

<?xml version="1.0" encoding="UTF-8"?>
<ScheduledMaintenance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScheduledMaintenance.xsd" Version="1.0">

How to get the Declaration Line to be created by the Xquery Mapper.


Thanks a bunch,

Hans Lutsch

Postnext
Alberto MassariSubject: Mapping - How Include the Schema info at top of file.
Author: Alberto Massari
Date: 15 Mar 2007 11:07 AM
Hi Hans,
the <?xml ?> processing instruction is added by the XSLT processor, and anyhow it's not really needed.
Why do you want it to appear?

Alberto

Postnext
Hans LutschSubject: Mapping - How Include the Schema info at top of file.
Author: Hans Lutsch
Date: 15 Mar 2007 11:18 AM
What I am doing is this:
The Boeing Aircraft Company requires Airlines to submit all of the maintenance records of maintenance work carried out on Boeing aircraft on a monthly basis in a specific format ( Airline Transport Association ATA SPEC2000 Schemas ). The submitted XML file must have the first few lines like the sample I included. Their receiving server then does validation etc before the file is placed into their production database. This then enables Boeing to utilize the data to build a better airplane, help operators with reliability problems etc. In return for this effort the contributing airline then also gets access to this enormous database for research purposes and to utilize the Boeing Reporting Tools to create nifty Monthly reports etc. on how your fleet is doing and also compare to the world fleet of Boeing aircraft.

I am using the Xquery Mapper to create the file required to send to Boeing. Am I to understand that I may have to put the created XML file through another process to provide the Declaration line or can't the Xquery return the required line?

Hans

Posttop
Alberto MassariSubject: Mapping - How Include the Schema info at top of file.
Author: Alberto Massari
Date: 15 Mar 2007 12:24 PM
Hi Hans,
the generation of the XML processing instruction should be controlled by a serialization option (omit-xml-declaration), so there is a way to generate it.
Unfortunately every XQuery implementation has taken a different path regarding serialization options, and Stylus doesn't provide an unified UI to control them.
So, you should do this:
- change the processor to be DataDirect XQuery
- add as a first line this instruction

declare option ddtek:serialize "indent=yes, omit-xml-declaration=no";

- run the menu option XQuery | Generate Java Code
- compile the resulting Java code and run it.

Hope this helps,
Alberto

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.