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="urn
asis: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>
<sts
ianExtensions>
<sts:InvoiceControl>
<sts:InvoiceAuthorization>18762010010595</sts:InvoiceAuthorization>
<sts:AuthorizationPeriod>
<cbc
tartDate>2018-09-01</cbc
tartDate>
<cbc:EndDate>2020-09-01</cbc:EndDate>
</sts:AuthorizationPeriod>
<sts:AuthorizedInvoices>
<sts
refix>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="urn
asis:names:specification:ubl:codelist:gc:CountryIdentificationCode-2.0">CO</cbc:IdentificationCode>
</sts:InvoiceSource>
</sts
ianExtensions>
</ext:ExtensionContent>
</ext:UBLExtension>
<ext:UBLExtension>
<ext:ExtensionContent>
</ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>UBL 2.0</cbc:UBLVersionID>
<cbc
rofileID>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/>
<cbc
ocumentCurrencyCode>COP</cbc
ocumentCurrencyCode>
<cac
rderReference><cbc:ID /></cac
rderReference>
<cac:AdditionalDocumentReference>
<cbc:ID>152872</cbc:ID>
<cbc
ocumentTypeCode>AAJ</cbc
ocumentTypeCode>
<cbc
ocumentType>Remision</cbc
ocumentType>
</cac:AdditionalDocumentReference>
<fe:AccountingSupplierParty>
<cbc:AdditionalAccountID>1</cbc:AdditionalAccountID>
<fe
arty>
<cac
artyIdentification>
<cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">805028041</cbc:ID>
</cac
artyIdentification>
<cac
artyName>
<cbc:Name>SUPERTIENDAS PRUEBA S A</cbc:Name>
</cac
artyName>
<fe
hysicalLocation>
<cbc
escription>CALLE 0 3443 214</cbc
escription>
<fe:Address>
<cbc
epartment>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>
</fe
hysicalLocation>
<fe
artyTaxScheme>
<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 />
</fe
artyTaxScheme>
<fe
artyLegalEntity>
<cbc:RegistrationName>SUPERTIENDAS PRUEBA S A</cbc:RegistrationName>
</fe
artyLegalEntity>
<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>
</fe
arty>
<cac:AccountingContact>
<cbc:Name>29707543</cbc:Name>
</cac:AccountingContact>
<cac
ellerContact>
<cbc:Name>ESCOBAR LLORDA MARIA PEREZ</cbc:Name>
</cac
ellerContact>
</fe:AccountingSupplierParty>
<fe:AccountingCustomerParty>
<cbc:AdditionalAccountID>2</cbc:AdditionalAccountID>
<fe
arty>
<cac
artyIdentification>
<cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">3493930</cbc:ID>
</cac
artyIdentification>
<fe
hysicalLocation>
<cbc
escription>CR 90a 18 33</cbc
escription>
<fe:Address>
<cbc
epartment>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>
</fe
hysicalLocation>
<fe
artyTaxScheme>
<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 />
</fe
artyTaxScheme>
<fe
artyLegalEntity><cbc:RegistrationName>GUILLERMO</cbc:RegistrationName></fe
artyLegalEntity>
<fe
erson>
<cbc:FirstName>GUILLERMO LEON</cbc:FirstName>
<cbc:FamilyName>SUAREZ JIMENEZ</cbc:FamilyName>
<cbc:MiddleName/>
</fe
erson>
</fe
arty>
</fe:AccountingCustomerParty>
<fe
elivery>
<fe
eliveryLocation>
<cbc
escription>GUILLERMO</cbc
escription>
<fe:Address>
<cbc:ID>CALI</cbc:ID>
</fe:Address>
</fe
eliveryLocation>
</fe
elivery>
<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>
<cbc
ercent>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>
<cbc
ayableAmount 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>
<cbc
ercent>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>
<cbc
escription>ARENA FREEMIAU*4500g GATOS</cbc
escription>
<cac
tandardItemIdentification>
<cbc:ID>086055</cbc:ID>
</cac
tandardItemIdentification>
</fe:Item>
<fe
rice>
<cbc
riceAmount currencyID="COP">60200.00</cbc
riceAmount>
</fe
rice>
</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>
<cbc
ercent>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>
<cbc
escription>ARENA FREEMIAU*10000g GATOS (10k)</cbc
escription>
<cac
tandardItemIdentification>
<cbc:ID>086056</cbc:ID>
</cac
tandardItemIdentification>
</fe:Item>
<fe
rice>
<cbc
riceAmount currencyID="COP">29740.00</cbc
riceAmount>
</fe
rice>
</fe:InvoiceLine>
</fe:Invoice>
Explore our Alfresco products with the links below. Use labels to filter content by product module.