for $reg in /Cuentas/Documento/control
	let $url := concat("C:/prueba_xquery/",encode-for-uri($reg/@cedula), ".xml"),
	$cedula := $reg/@cedula,
	$salida := 
			<Cuentas>
			<Documento>
					{$reg}
					{/Cuentas/Documento/encabezado[position() = $reg/position()]}
					{/Cuentas/Documento/saldoAFavor[position() = $reg/position()]}
					{/Cuentas/Documento/cadivi[position() = $reg/position()]}
					{/Cuentas/Documento/detalleCuenta[position() = $reg/position()]}
				</Documento>
			</Cuentas>

return 
( ddtek:serialize-to-url($salida,$url,"omit-xml-declaration=no,indent=yes"))
(: Stylus Studio meta-information - (c) 2004-2009. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" useresolver="yes" url="result_convertToXML.xml" outputurl="" processortype="datadirect" tcpport="0" profilemode="0" profiledepth="" profilelength=""
		          urlprofilexml="file:///c:/Documents and Settings/William Basabe/Mis documentos/JMC/Cliente/COPRBANCA/profile.xml" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline=""
		          postprocessadditionalpath="" postprocessgeneratedext="" host="" port="3408" user="" password="" validateoutput="no" validator="internal" customvalidator="">
			<advancedProperties name="bSchemaAware" value="true"/>
			<advancedProperties name="bXml11" value="false"/>
			<advancedProperties name="iValidation" value="0"/>
			<advancedProperties name="bExtensions" value="true"/>
			<advancedProperties name="iWhitespace" value="0"/>
			<advancedProperties name="bTinyTree" value="true"/>
			<advancedProperties name="bUseDTD" value="false"/>
			<advancedProperties name="bWarnings" value="true"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no">
			<SourceSchema srcSchemaPath="MUESTRA DATA\001_RCP_PERSONAL_VERDE\001_RCP_PERSONAL_VERDE_corpbanca_amex.xml" srcSchemaRoot="Cuentas" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/>
		</MapperInfo>
		<MapperBlockPosition>
			<template name="xquery_body">
				<block path="flwr" x="232" y="0"/>
				<block path="flwr/distinct-values[0]" x="186" y="0"/>
				<block path='( ddtek:serialize-to-url($salida,$url,"omit-xml-declaration=no,indent=yes"))' x="182" y="0"/>
			</template>
		</MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
:)