标签云

微信群

扫码加入我们

WeChat QR Code

Dear Stackoverflowers:I need your kind help to accomplish the following task: I need a master computer to be able to download a predefined XML file then parse it; with the available info, a script should identify the correct file to be downloaded from a web server periodically. Finally this file must be transfered to another computer without internet access in the same LAN and extract it to a given location. However I have bounds: I can't use PHP to accomplish this because and I can't install anything there; I've proposed to do this via MD5sums but a given day and hour must be given to be able to download the file to the master computer and another hour and day to transfer it to the slim terminal.I'll explain then ask. Thanks!I've designed this XML:<?xml version="1.0"?><updateXML id="subdirectory1"><file><tarname>compressedFile.tar.gz</tarname><name>fileInsideName</name><filExtension>.ext</filExtension><url protocol="http://">someurl.com/mainDirectory</url></file><update><download>2012-02-02T03:00:00.00000</download><copyTo terminal="1">2012-02-02T09:00:00.00000</copyTo></update></updateXML>And this working XML Schema (XSD)<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:element name="updateXML"><xsd:complexType><xsd:sequence><xsd:element name="file" minOccurs="1" maxOccurs="unbounded"><xsd:complexType><xsd:all><xsd:element name="tarname" type="xsd:string"/><xsd:element name="name" type="xsd:string"/><xsd:element name="filExtension" type="xsd:string"/><xsd:element name="url"><xsd:complexType><xsd:simpleContent><xsd:extension base="xsd:string"><xsd:attribute name="protocol" type="xsd:string" /></xsd:extension></xsd:simpleContent></xsd:complexType></xsd:element></xsd:all></xsd:complexType></xsd:element><xsd:element name="update" minOccurs="1" maxOccurs="1"><xsd:complexType><xsd:sequence><xsd:element name="download" type="xsd:dateTime" /><xsd:element name="copyTo"><xsd:complexType><xsd:simpleContent><xsd:extension base="xsd:string"><xsd:attribute name="terminal" type="xsd:int" /></xsd:extension></xsd:simpleContent></xsd:complexType></xsd:element></xsd:sequence></xsd:complexType></xsd:element></xsd:sequence><xsd:attribute name="id" type="xsd:string"/></xsd:complexType></xsd:element></xsd:schema>I've researched and I've found XMLlint can parse XML files. No problems here now:$ xmllint --noout --schema updatemenus.xsd updatemenus.xml updatemenus.xml validatesI've thought in a process that can help me accomplish the given task. Please tell me if my proposed steps are correct:Generate the XML and validate it with it's XSD.Download it to the master computer and parse it there. Use the available info to construct a complete URL to download.Once downloaded secure copy it to the needed terminal in the LANCheck if a newer XML it's available and download it (a cron process?)Do you think this is correct? If so, now that my XML it's valid, NOW WHAT??? ='/How can I use it's info?? I'm new to XMLlint and to XPath. What can I do now???Thanks a lot.


Can you FTP? What platform are you on? Do you have CRON or Scheduled Tasks available?

2019年04月18日33分54秒

mmcglynn Thanks for answering ;) I can't FTP. The files to be downloaded and the XML must reside in a webserver. I'm working on Linux Ubuntu (the slim clients have have Lubuntu). There are crons tasks available in the master computer (the middle one!) and all this it's supposed to be done via a cron task =/ I'm clueless really... =(

2019年04月18日33分54秒

Well, CRON looks more complicated than it is, and there are LOTS of example, since this stuff has been around forever. You can do it!

2019年04月18日33分54秒

mmcglynn Thanks I'll do my best <=) It's a little complicated because of the time remaining for me to finish this. I'm more experienced with PHP and CSS =P this is different. Now I'm trying to see what to do next with the parsed XML u.u

2019年04月18日33分54秒

shelter Thanks for helping me, don't worry. Yes I know this, thanks. If I check my XSD against this URL you gave me, there are no problems: xmllint --noout -schema http://www.w3.org/2001/XMLSchema.xsd updateFiles.xsdupdateFiles.xsd validates However as said in my post, if I check my XML against my valid XSD I got that error... What could be the reason? u_u THANKS!

2019年04月18日33分54秒

shelter Thanks but maybe I didn't understand correctly =( I've added to the URL the .xsd extension, and I even downloaded the whole XMLSchema.xsd and tried to validate against it, but it's the very same behavior =(

2019年04月18日33分54秒

shelter I found the error! =D the problem was in my XSD. I just wrote type="dateTime" but it should have been type="xsd:dateTime" Thanks anyway...NOW WHAT? U__U I've parsed the XML, now how can I use it? =(

2019年04月18日33分54秒

For some info on crontab, see my answer at stackoverflow.com/questions/6284149/… Good luck.

2019年04月18日33分54秒