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
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Myke GallacherSubject: XML to Flat File
Author: Myke Gallacher
Date: 09 Dec 2008 01:09 AM
I am converting an XML doc to flat file comma seperator (CSV).

I can concatenate the values ok, with the result set looking fine but the doc only returns 1 row?? any pointers?

Postnext
Alberto MassariSubject: XML to Flat File
Author: Alberto Massari
Date: 09 Dec 2008 02:55 AM
Hi Myke,
can you show us the source XML and the XSLT you wrote?

Thanks,
Alberto

Postnext
Myke GallacherSubject: XML to Flat File
Author: Myke Gallacher
Date: 09 Dec 2008 02:45 PM
as you may gather I am a complete rookie at XML

Postnext
Myke GallacherSubject: XML to Flat File
Author: Myke Gallacher
Date: 09 Dec 2008 02:43 PM
XSLT

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://www.xxxx.xxx.uk/DataStandards/XMLschema/CDS/ns">
<xsl:template match="/">
<XML_FLAT>
<xsl:for-each select="concat(concat(ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeSenderIdentity,',',
ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeReceiverIdentity,',',
ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeControlReference,',',
ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeDateOfPreparation,',',
ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeTimeOfPreparation,',',
ns:CDS-XMLInterchange/ns:CDSInterchangeHeader/ns:CDSInterchangeApplicationReference),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/@CDSProtocolIdentifier,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/@CDSType),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSMessageHeader/ns:CDSMessageType,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSMessageHeader/ns:CDSMessageVersionNumber,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSMessageHeader/ns:CDSMessageReferenceNumber,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSMessageHeader/ns:CDSMessageRecordIdentifier),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSType,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSProtocolIdentifier,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSUniqueIdentifier,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSUpdateType,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSApplicableDate,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSApplicableTime,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:CDSActivityDate,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:OrganisationCode_CDSSenderIdentity,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSTransactionHeader_NetChange/ns:OrganisationCode_CDSPrimeRecipientIdentity),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:LocalPatientIdentifier,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:OrganisationCode_LocalPatientIdentifier),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:UnvalidatedNHSNo_Structure/@UnvalidatedNHSNumberStatusIndicator,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:UnvalidatedNHSNo_Structure/ns:NHSNumber,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:UnvalidatedNHSNo_Structure/ns:NHSNumberStatusIndicator,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:UnvalidatedNHSNo_Structure/ns:PostcodeOfUsualAddress,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:UnvalidatedNHSNo_Structure/ns:OrganisationCode_PCTOfResidence),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:ValidatedNHSNo_Structure/@ValidatedNHSNumberStatusIndicator,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:ValidatedNHSNo_Structure/ns:NHSNumber,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:ValidatedNHSNo_Structure/ns:NHSNumberStatusIndicator,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:ValidatedNHSNo_Structure/ns:PostcodeOfUsualAddress,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientIdentity_General_Structure/ns:ValidatedNHSNo_Structure/ns:OrganisationCode_PCTOfResidence),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientCharacteristics_AAndE_Structure/ns:PersonBirthDate,',',
ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientCharacteristics_AAndE_Structure/ns:PersonGenderCurrent,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:PersonGroupPatient_AAndE_Structure/ns:PatientCharacteristics_AAndE_Structure/ns:CarerSupportIndicator),',',
concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:GPRegistration/ns:GMP_CodeOfRegisteredOrReferringGMP,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:GPRegistration/ns:CodeOfGPPractice_RegisteredGMP),',',

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEArrivalMode,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEAttendanceCategory,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEAttendanceDisposal,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEIncidentLocationType,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:SourceOfReferralForAAndE,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEDepartmentType,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:ArrivalDate,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:ArrivalTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AgeAtCDSActivityDate,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEInitialAssessmentTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndETimeSeenForTreatment,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEDepartureTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:AAndEPatientGroup,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:HealthcareResourceGroupCode,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ActivityCharacteristics/ns:HealthcareResourceGroupCode_VersionNumber),',',

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ServiceAgreementDetails/ns:CommissioningSerialNumber,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ServiceAgreementDetails/ns:ProviderReferenceNumber,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ServiceAgreementDetails/ns:OrganisationCode_CodeOfProvider,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ServiceAgreementDetails/ns:OrganisationCode_CodeOfCommissioner),',',

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:PersonGroupAAndEConsultant/ns:AAndEStaffMemberCode,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalInvestigationDetails/ns:ClinicalInvestigationGroupAAndE/ns:InvestigationSchemeInUse,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalInvestigationDetails/ns:ClinicalInvestigationGroupAAndE/ns:PrimaryInvestigationGroupAAndE/ns:PrimaryInvestigation_AAndE,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalInvestigationDetails/ns:ClinicalInvestigationGroupAAndE/ns:SecondaryInvestigationGroupAAndE/ns:SecondaryInvestigation_AAndE,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalTreatmentDetails/ns:ClinicalTreatmentGroupAandE/ns:ProcedureSchemeInUse,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalTreatmentDetails/ns:ClinicalTreatmentGroupAandE/ns:PrimaryTreatmentGroupAAndE/ns:PrimaryTreatment_AAndE,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalTreatmentDetails/ns:ClinicalTreatmentGroupAandE/ns:PrimaryTreatmentGroupAAndE/ns:ProcedureDate,','),

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalTreatmentDetails/ns:ClinicalTreatmentGroupAandE/ns:SecondaryTreatmentGroupAAndE/ns:SecondaryTreatment_AAndE,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:AttendanceOccurrence/ns:ClinicalTreatmentDetails/ns:ClinicalTreatmentGroupAandE/ns:SecondaryTreatmentGroupAAndE/ns:ProcedureDate),',',

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEArrivalMode,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEAttendanceCategory,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEAttendanceDisposal,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEIncidentLocationType,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:SourceOfReferralForAAndE,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEDepartmentType,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:ArrivalDate,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:ArrivalTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AgeAtCDSActivityDate,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEInitialAssessmentTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndETimeSeenForTreatment,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEDepartureTime,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:AAndEPatientGroup,'',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:HealthcareResourceGroupCode,',',ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ActivityCharacteristics/ns:HealthcareResourceGroupCode_VersionNumber),',',

concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:AccidentAndEmergencyAttendance/ns:HealthcareResourceGroupActivity/ns:ClinicalActivityGroup,''),'',concat(ns:CDS-XMLInterchange/ns:CDSNetChange-All-MessageTypes/ns:CDSMessageTrailer/ns:CDSMessageReferenceNumber,','),

concat(ns:CDS-XMLInterchange/ns:CDSInterchangeTrailer/ns:CDSInterchangeControlReference,',',ns:CDS-XMLInterchange/ns:CDSInterchangeTrailer/ns:CDSInterchangeControlCount,',',ns:CDS-XMLInterchange/ns:CDSInterchangeTrailer/ns:CDSInterchangeSenderIdentity,',',ns:CDS-XMLInterchange/ns:CDSInterchangeTrailer/ns:CDSInterchangeReceiverIdentity))"/>
</XML_FLAT>
</xsl:template>
</xsl:stylesheet>

Posttop
Alberto MassariSubject: XML to Flat File
Author: Alberto Massari
Date: 09 Dec 2008 03:53 PM
Hi Myke,
can you attach also the XML document? Given the names of the field used in the XSLT stylesheet, it's not clear which one are the repetitions.
Can you also add a sample of how the output should look like for that specific instance of XML?

Alberto

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.