10-30-2018 11:15 AM
In alfresco community 5.2 I need to read the contents of an XML file when the file is uploaded to a site
10-30-2018 05:11 PM
What is stopping you from doing that? Without more information about exactly what you are trying to do and where you are stuck we aren't going to be much help, I'm afraid. Sorry.
10-31-2018 09:09 AM
Gracias por su respuesta
Lo que requiero es cargar un archivo xml en Alfresco, y a través de una
regla ejecutar un script que "lea" algunos datos del archivo que cargó y
los asigne a unas propiedades personalizadas y después distribuya en
carpetas según algunos valores del archivo.
Estoy trabajando en Alfresco community 5.2
Al ejecutar el script para leer el archivo genera un error :...
The processing instruction target matching "[xX][mM][lL]" is not allowed
....
Sandra I. Vásquez R.
*
11-03-2018 12:01 AM
Donde esta tu script? Puedes lo mostrar aqui? No puedo ayudarte sin el codigo.
11-05-2018 03:21 PM
Hola
El código del script es :
// buscamos la carpeta logsXML - la creamos si no existe
var carpetaBackup = space.childByNamePath("logsXML");
if (carpetaBackup == null && space.hasPermission("CreateChildren"))
{
// crear la carpeta por primera vez
carpetaBackup = space.createFolder("logsXML");
}
// record the time of the backup to a log file
var logFile = carpetaBackup .childByNamePath("archilogXML.txt");
if (logFile == null)
{
logFile = carpetaBackup .createFile("archilogXML.txt");
}
if (logFile != null)
{
if (document.mimetype == "text/xml")
{
var docuname = document.name;
var mimetype = document.properties.content.mimetype;
var docString = document.content;
if (docString.startsWith("<?xml")) {
docString = docString.split("\n").slice(1).join("\n")
}
var docXml = new XML(docString);
nuevoNombre = docXml.phoneEntry.name;
logFile.content += "Tipo Archivo: " + mimetype +
"\tFecha: " + new Date().toGMTString() +
"\tDoc Name: " + docuname +
"\tNuevo Nombre: " + nuevoNombre +
"\tContenido Archivo- docXml: " + docXml + "\r\n";
}
}
Cuando reviso el archivo creado para el seguimiento del proceso, en Nuevo nombre que es donde quedaría el dato que se debe extraer del xml no aparece nada, como si no interpretara el archivo XML.
Gracias
11-08-2018 11:05 PM
Si tu xml es como este:
<phoneEntry>
<name>Jeff</name>
</phoneEntry>
Entonces tu puede conseguir el nombre como este:
docXml.name
Necisita estar sin phoneEntry.
11-08-2018 11:07 PM
Tambien deberias conseguir el console de JavaScript si tu no lo tienes.
11-13-2018 07:40 AM
Buend día
Gracias por su colaboración, efectivamente me funcionó sin la etiqueta phoneEntry, pero cuando se tienen archivos con otro tipo de etiquetas no funciona continua el error, por ejemplo
<cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">3493930</cbc:ID>
Se requiere extraer el dato: 3493930
o en etiquetas como:
<cbc:LineExtensionAmount currencyID="COP">201142.00</cbc:LineExtensionAmount>
Quedo pendiente de aclaraciones al respecto.
Gracias
11-15-2018 11:11 AM
Buen día,
Yo tengo ver el codigo complete, tu xml complete, y algunos mensajes de error o no puedo ayudarte.
Jeff
11-15-2018 11:35 AM
Gracias por estar pendiente de responder
Anexo un documento xml para revisión
Y en este momento no me genera error la carga del xml, imprimo en el log la variable que contiene los datos del xml cargados pero al extraer los datos no deja nada en la variable
Y se requiere extraer los datos de la etiqueta:
<cac:AccountingContact>
<cbc:Name>29707543</cbc:Name>
</cac:AccountingContact>
He probado con
nuevoNombre = docXml.AccountingContact.Name
También con
nuevoNombre = docXml.Name
También con
nuevoNombre = docXml.cbc:Name
Archivo que cargo como ejemplo:
<?xml version="1.0" encoding="UTF-8"?>
<fe:Invoice xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns:cac="urnasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn
asis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" xmlns:clm5639="urn:un:unece:uncefact:codelist:specification:5639:1988" xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001" xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn
asis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn
asis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sts="http://www.dian.gov.co/contratos/facturaelectronica/v1/Structures" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dian.gov.co/contratos/facturaelectronica/v1 http://www.dian.gov.co/contratos/facturaelectronica/v1%20../xsd/DIAN_UBL.xsd%20urn:un:unece:uncefact...
" xmlns:grl="urn:General:names:specification:ubl:colombia:schema:xsd:GeneralAggregateComponents-1">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent>
<stsianExtensions>
<sts:InvoiceControl>
<sts:InvoiceAuthorization>18762010010595</sts:InvoiceAuthorization>
<sts:AuthorizationPeriod>
<cbctartDate>2018-09-01</cbc
tartDate>
<cbc:EndDate>2020-09-01</cbc:EndDate>
</sts:AuthorizationPeriod>
<sts:AuthorizedInvoices>
<stsrefix>P1</sts
refix>
<sts:From>000000001</sts:From>
<sts:To>000100000</sts:To>
</sts:AuthorizedInvoices>
</sts:InvoiceControl>
<sts:InvoiceSource>
<cbc:IdentificationCode listAgencyID="6" listAgencyName="United Nations Economic Commission for Europe" listSchemeURI="urnasis:names:specification:ubl:codelist:gc:CountryIdentificationCode-2.0">CO</cbc:IdentificationCode>
</sts:InvoiceSource>
</stsianExtensions>
</ext:ExtensionContent>
</ext:UBLExtension>
<ext:UBLExtension>
<ext:ExtensionContent>
</ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>UBL 2.0</cbc:UBLVersionID>
<cbcrofileID>DIAN 1.0</cbc
rofileID>
<cbc:ID>P12542</cbc:ID>
<cbc:IssueDate>2018-10-29</cbc:IssueDate>
<cbc:IssueTime>10:44:00</cbc:IssueTime>
<cbc:InvoiceTypeCode listAgencyID="195" listAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" listSchemeURI="http://www.dian.gov.co/contratos/facturaelectronica/v1/InvoiceType">1</cbc:InvoiceTypeCode>
<cbc:Note/>
<cbcocumentCurrencyCode>COP</cbc
ocumentCurrencyCode>
<cacrderReference><cbc:ID /></cac
rderReference>
<cac:AdditionalDocumentReference>
<cbc:ID>152872</cbc:ID>
<cbcocumentTypeCode>AAJ</cbc
ocumentTypeCode>
<cbcocumentType>Remision</cbc
ocumentType>
</cac:AdditionalDocumentReference>
<fe:AccountingSupplierParty>
<cbc:AdditionalAccountID>1</cbc:AdditionalAccountID>
<fearty>
<cacartyIdentification>
<cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">805028041</cbc:ID>
</cacartyIdentification>
<cacartyName>
<cbc:Name>SUPERTIENDAS PRUEBA S A</cbc:Name>
</cacartyName>
<fehysicalLocation>
<cbcescription>CALLE 0 3443 214</cbc
escription>
<fe:Address>
<cbcepartment>VALLE</cbc
epartment>
<cbc:CitySubdivisionName/>
<cbc:CityName>PALMIRA</cbc:CityName>
<cac:AddressLine>
<cbc:Line>CALLE 0 3443 214</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>CO</cbc:IdentificationCode>
</cac:Country>
</fe:Address>
</fehysicalLocation>
<feartyTaxScheme>
<cbc:TaxLevelCode listName="TIPOS OBLIGACIONES-RESPONSABILIDADES:2016" listSchemeURI="http://www.dian.gov.co" name="Obligado a Facturar Electrónicamente Modelo 2242">O-37</cbc:TaxLevelCode>
<cac:TaxScheme />
</feartyTaxScheme>
<feartyLegalEntity>
<cbc:RegistrationName>SUPERTIENDAS PRUEBA S A</cbc:RegistrationName>
</feartyLegalEntity>
<cac:Contact>
<cbc:Name>SUPERTIENDAS PRUEBA S A</cbc:Name>
<cbc:Telephone>48232175</cbc:Telephone>
<cbc:Telefax>33234321</cbc:Telefax>
<cbc:ElectronicMail></cbc:ElectronicMail>
</cac:Contact>
</fearty>
<cac:AccountingContact>
<cbc:Name>29707543</cbc:Name>
</cac:AccountingContact>
<cacellerContact>
<cbc:Name>ESCOBAR LLORDA MARIA PEREZ</cbc:Name>
</cacellerContact>
</fe:AccountingSupplierParty>
<fe:AccountingCustomerParty>
<cbc:AdditionalAccountID>2</cbc:AdditionalAccountID>
<fearty>
<cacartyIdentification>
<cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">3493930</cbc:ID>
</cacartyIdentification>
<fehysicalLocation>
<cbcescription>CR 90a 18 33</cbc
escription>
<fe:Address>
<cbcepartment>VALLE</cbc
epartment>
<cbc:CitySubdivisionName/>
<cbc:CityName>CALI</cbc:CityName>
<cac:AddressLine>
<cbc:Line>CR 90a 18 33</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>CO</cbc:IdentificationCode>
</cac:Country>
</fe:Address>
</fehysicalLocation>
<feartyTaxScheme>
<cbc:TaxLevelCode listName="TIPOS OBLIGACIONES-RESPONSABILIDADES:2016" listSchemeURI="http://www.dian.gov.co" name="Ventas régimen común">O-11</cbc:TaxLevelCode>
<cac:TaxScheme />
</feartyTaxScheme>
<feartyLegalEntity><cbc:RegistrationName>GUILLERMO</cbc:RegistrationName></fe
artyLegalEntity>
<feerson>
<cbc:FirstName>GUILLERMO LEON</cbc:FirstName>
<cbc:FamilyName>SUAREZ JIMENEZ</cbc:FamilyName>
<cbc:MiddleName/>
</feerson>
</fearty>
</fe:AccountingCustomerParty>
<feelivery>
<feeliveryLocation>
<cbcescription>GUILLERMO</cbc
escription>
<fe:Address>
<cbc:ID>CALI</cbc:ID>
</fe:Address>
</feeliveryLocation>
</feelivery>
<fe:TaxTotal>
<cbc:TaxAmount currencyID="COP">38217.00</cbc:TaxAmount>
<cbc:TaxEvidenceIndicator>false</cbc:TaxEvidenceIndicator>
<fe:TaxSubtotal>
<cbc:TaxableAmount currencyID="COP">201142.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="COP">38217.00</cbc:TaxAmount>
<cbcercent>19.00</cbc
ercent>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>01</cbc:ID>
<cbc:TaxTypeCode>01</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</fe:TaxSubtotal>
</fe:TaxTotal>
<fe:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="COP">201142.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="COP">201142.00</cbc:TaxExclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="COP">0.00</cbc:AllowanceTotalAmount>
<cbcayableAmount currencyID="COP">239359.00</cbc
ayableAmount>
</fe:LegalMonetaryTotal>
<fe:InvoiceLine>
<cbc:ID>01</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">2</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="COP">101176.00</cbc:LineExtensionAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReasonCode>01</cbc:AllowanceChargeReasonCode>
<cbc:AllowanceChargeReason>Descuento Linea</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="COP">0.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="COP">19223.00</cbc:TaxAmount>
<cbc:TaxEvidenceIndicator>false</cbc:TaxEvidenceIndicator>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="COP">120399.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="COP">19223.00</cbc:TaxAmount>
<cbcercent>19.00</cbc
ercent>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>01</cbc:ID>
<cbc:TaxTypeCode>01</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<fe:Item>
<cbcescription>ARENA FREEMIAU*4500g GATOS</cbc
escription>
<cactandardItemIdentification>
<cbc:ID>086055</cbc:ID>
</cactandardItemIdentification>
</fe:Item>
<ferice>
<cbcriceAmount currencyID="COP">60200.00</cbc
riceAmount>
</ferice>
</fe:InvoiceLine>
<fe:InvoiceLine>
<cbc:ID>02</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">4</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="COP">99966.00</cbc:LineExtensionAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReasonCode>01</cbc:AllowanceChargeReasonCode>
<cbc:AllowanceChargeReason>Descuento Linea</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="COP">0.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="COP">18994.00</cbc:TaxAmount>
<cbc:TaxEvidenceIndicator>false</cbc:TaxEvidenceIndicator>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="COP">118960.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="COP">18994.00</cbc:TaxAmount>
<cbcercent>19.00</cbc
ercent>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>01</cbc:ID>
<cbc:TaxTypeCode>01</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<fe:Item>
<cbcescription>ARENA FREEMIAU*10000g GATOS (10k)</cbc
escription>
<cactandardItemIdentification>
<cbc:ID>086056</cbc:ID>
</cactandardItemIdentification>
</fe:Item>
<ferice>
<cbcriceAmount currencyID="COP">29740.00</cbc
riceAmount>
</ferice>
</fe:InvoiceLine>
</fe:Invoice>
Explore our Alfresco products with the links below. Use labels to filter content by product module.