CN104376008A - Method for replacing XML (extensive markup language) absolute path - Google Patents

Method for replacing XML (extensive markup language) absolute path Download PDF

Info

Publication number
CN104376008A
CN104376008A CN 201310353703 CN201310353703A CN104376008A CN 104376008 A CN104376008 A CN 104376008A CN 201310353703 CN201310353703 CN 201310353703 CN 201310353703 A CN201310353703 A CN 201310353703A CN 104376008 A CN104376008 A CN 104376008A
Authority
CN
Grant status
Application
Patent type
Prior art keywords
xml
absolute path
path
absolute
file
Prior art date
Application number
CN 201310353703
Other languages
Chinese (zh)
Inventor
周国明
黄雷
王耿博
Original Assignee
深圳市众鸿科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/30Information retrieval; Database structures therefor ; File system structures therefor
    • G06F17/30908Information retrieval; Database structures therefor ; File system structures therefor of semistructured data, the undelying structure being taken into account, e.g. mark-up language structure data
    • G06F17/30914Mapping or conversion
    • G06F17/30917Mapping to a database

Abstract

The invention relates to a method for replacing an XML (extensive markup language) absolute path. The method comprises the following steps of (S100) reading an XML file; (S200) retrieving the start tag and the end tag of an element in the XML file; (S300) extracting a first absolute path between the start tag and the end tag of the element; (S400) inserting a second absolute path between the start tag and the end tag of the element; and (S500) saving the XML file. The method for replacing the XML absolute path is capable of quickly replacing the absolute path in the XML file and ensuring that the XML file can be correctly displayed and operated on different platforms. By recording each replacement, absolute paths of a plurality of XML files can be replaced in bulk. The workload is greatly reduced, and the working efficiency is improved.

Description

XML绝对路径转换方法 XML absolute path conversion method

技术领域 FIELD

[0001] 本发明涉及XML技术,更具体地说,涉及一种XML绝对路径转换方法。 [0001] The present invention relates to XML technology, and more particularly, to a method of converting XML absolute path.

背景技术 Background technique

[0002] 可扩展标记语言(Extensible Markup Language, XML),是一种用于标记电子文件使其具有结构性的标记语言,可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。 [0002] Extensible Markup Language (Extensible Markup Language, XML), is a method for marking an electronic document to have a structured markup language, can be used to mark data, defined data types, allow a user of their markup language that defines the source language. XML文件能够应用在程序的界面设计、多格式文档生成等领域。 XML files can be used in the program interface design, multi-format document generation and other fields. 在XML文件中能够通过路径的方式插入例如图片等多媒体元素,但是在开发的过程中常常出现文件的移交来协同工作,这时候多媒体元素所使用的绝对路径时常会出现无法正常指向的问题,导致页面无法正常显示。 In the XML file can be inserted by way of a path, such as pictures and other multimedia elements, but handed over documents often appear in the development process to work, this time the absolute path of the multimedia elements used often problems can not be directed properly, resulting in page can not be displayed properly.

发明内容 SUMMARY

[0003] 本发明的目的在于,针对现有的XML文件在使用绝对路径的时候,会在不同的平台上出现无法正常使用的问题,提供一种XML绝对路径转换方法以克服上述缺陷。 [0003] The object of the present invention, when using an absolute path, the problem will not occur in normal use on different platforms for the existing XML file, there is provided a method of converting XML absolute path to overcome the above drawbacks.

[0004] 本发明解决上述问题的方案是,提供一种XML绝对路径转换方法,包括以下的步骤: [0004] The embodiment of the present invention is to solve the above problems, to provide an absolute path XML conversion method, comprising the steps of:

[0005] S100、读取XML 文件; [0005] S100, read the XML file;

[0006] S200、检索XML文件中的元素标签起始符与元素标签结束符; [0006] S200, retrieve the XML document element start symbol and the tag label terminator element;

[0007] S300、提取元素标签起始符与元素标签结束符之间的第一绝对路径; [0007] S300, the extracted start character element tag with the element end tag between the first absolute path identifier;

[0008] S400、将第二绝对路径插入元素标签起始符与元素标签结束符之间; [0008] S400, the second element is inserted into the absolute path starting tag label symbol elements between the end of the character;

[0009] S500、保存XML 文件。 [0009] S500, save the XML file.

[0010] 本发明的XML绝对路径转换方法,其中步骤S300还包括: [0010] XML absolute path conversion method of the present invention, wherein further comprising the step S300:

[0011] S301、提取XML文件中与第一绝对路径相同的绝对路径地址。 [0011] S301, same as the first extract the absolute path absolute path in the XML file.

[0012] 本发明的XML绝对路径转换方法,其中步骤S400还包括: [0012] XML absolute path conversion method of the present invention, wherein further comprising the step S400:

[0013] 将第二绝对路径放入元素标签起始符与元素标签结束符之间。 [0013] The second path into an absolute tag element start symbol and end element tags between character.

[0014] 本发明的XML绝对路径转换方法,还包括S600: [0014] XML absolute path switching method of the present invention, further comprising S600:

[0015] 生成记录文件,记录文件记录第一绝对路径与第二绝对路径。 [0015] generated log file, the log file records a first and a second absolute path absolute path.

[0016] 本发明的XML绝对路径转换方法,第一绝对路径包括依次排列的第一路径索引和第一文件索引;第二绝对路径包括依次排列的第二路径索引和第二文件索引;第一文件索引与第二文件索引相同;在步骤S300中提取第一绝对路径的第一路径索引,在步骤S400中将第二路径索引放入元素标签起始符与元素标签结束符之间。 [0016] XML absolute path switching method of the present invention, the first absolute path comprises a first path and a first index file index arranged sequentially; a second path comprises a second absolute path index and the second index file are sequentially arranged; first the index file index and the same second file; extracting a first index path first absolute path in step S300, the start code into element tags and tag elements in a second path between the end of symbol index in step S400.

[0017] 本发明的XML绝对路径转换方法,还包括读取记录文件,依据记录文件中的记录的第一绝对路径与第二绝对路径,对其他XML文件进行绝对路径转换。 [0017] XML absolute path switching method of the present invention, further comprising a log file is read, the absolute path according to the first record in the file recorded in the second absolute path, other XML file absolute path switching.

[0018] 实施本发明的XML绝对路径转换方法能够快速对XML中的绝对路径进行替换,使得XML文件能够在不同的平台上正常显示工作。 [0018] XML absolute path switching method of the present invention is capable of quickly XML absolute path Alternatively, the XML file can be normally displayed so that operate on different platforms. 通过记录每一次的替换,使得对多个XML文件能够进行批量的替换操作,大大减小了工作量,提高了工作效率。 With each replacement recording, so that a plurality of XML files that can replace the batch operation, the workload is greatly reduced, improving the work efficiency.

附图说明 BRIEF DESCRIPTION

[0019] 以下结合附图对本发明进行说明,其中: [0019] conjunction with the drawings of the present invention will be described, wherein:

[0020] 图1为本发明XML文件中引用图片的示意图; [0020] FIG 1 XML files present invention, a schematic view of a reference image;

[0021] 图2为本发明XML绝对路径转换方法的方法流程图; [0021] FIG. 2 is a method of converting the absolute path XML flowchart of a method invention;

[0022] 图3为本发明XML绝对路径转换方法中生成的记录文件示意图。 [0022] FIG. 3 is a schematic view of XML absolute path switching method of generating a log file to the invention.

具体实施方式 Detailed ways

[0023] 如图1所示为本发明中涉及的XML文件的示意图,以图片为例,当需要在XML文件100中插入Iv图片的时候,在图片标签起始符110和图片标签结束符130之间插入个绝对路径120。 XML file shown a schematic view of the present invention relates to the [0023] As shown in FIG 1, an example of pictures when pictures need to insert Iv in the XML file 100 when the picture start code 110 and the tag image tag terminator 130 inserted between the absolute path 120. 图片标签起始符110为代表图片要素的“pic”与尖括号“〈”和“〉”的结合,而图片标签结束符130则对应在“pic”如加入反斜杠“\”。 Label start character image represented by picture element 110 "PIC" angle brackets "<" and ">" in conjunction with the end character image tag 130 corresponds to "PIC", such as a backslash '\. " 在图片标签起始符110和图片标签结束符130之间的绝对路径120则为需要插入的图像文件在当前平台上的完整地址。 In the picture start code 110 and the tag label image path between the end of the absolute address character 130 120 it was necessary to insert the complete image file on the current platform. 以上仅为插入图片的情形,当需要插入不同的元素的时候,则需要将图片标签起始符110和图片标签结束符130对应改为适当的元素标签起始符和元素标签结束符。 Above is merely inserted into the picture case, when the need to insert a different element of the time, it is necessary to picture start code 110 and the label image corresponding to the tab 130 to a suitable terminator element tag label start character and terminator elements. 一方面由于在不同的平台中对于文件管理的方式不同,例如图1中的绝对路径120为“C:\windows\l.jpg”是在windows平台下的表达,但是在Linux中的表达很可能为“/mnt/sdal/1.jpg”,且不同的开发人员在同一种平台上对于文件的保存位置一般也不同,这样当XML文件100转到其他平台的时候,很容易就会出现绝对路径120无法匹配到原先定义的文件上,导致XML文件的无法正常使用。 For file management on the one hand due to the different ways in different platforms, such as 120 in Figure 1. absolute path "C: \ windows \ l.jpg" is expressed in the windows platform, but expressed in Linux is likely to as "/mnt/sdal/1.jpg", and different developers on the same platform to save the file in general it is different, so that when the XML file 100 transferred to other platforms, it is very easy there will be an absolute path 120 can not be matched to the original file defined, making it impossible to use normal XML files.

[0024] 为此本发明采用了如图2的方法对绝对路径进行转换。 [0024] The method of the present invention is used for this purpose as shown in FIG. 2 absolute path conversion. 首先在步骤SlOO中,开发者先使用编辑器打开需要进行操作的XML文件,例如图1中的XML文件100。 First, in step SlOO, the developer to open the XML file using the editor needs to operate, such XML file 100 of FIG. 然后在步骤S200中查找出兀素标签起始符与兀素标签结束符,例如图1中的〈pic>和〈\pic> ;然后在步骤S300中提取出绝对路径,由于XML文件中,可以使用嵌套的标签,因此在此步骤中首先将<pic>和<\pic>之间的其他标签符剔除,以剩下路径地址,然后确定该路径地址是绝对路径还是相对路径:所有的相对路径均以点号”开始,对于相对路径不做处理,仅将绝对路径从元素标签起始符与元素标签结束符之间提取出来,对于该分离出来的路径地址则为第一绝对路径;然后在步骤S400中,我们将新的路径地址,即第二绝对路径,插入到原先第一绝对路径的位置上,完成替换操作;此后对于整个XML文件进行与上面步骤相似的操作,使得整个XML文件都完成替换操作,即在步骤S300中进一步的进行步骤S301,对整个XML文件查找与前面步骤中第一绝度路径相同的路径地址进行 Then in the step S200, the start code and the tag element Wu Wu hormone terminator label, e.g. in FIG. 1 <pic> and <\ pic>; absolute path then extracted in step S300, since the XML file, can be using nested tags, so this step is first <pic> tag and other symbols excluding between <\ pic>, to leave a path address, then the address is determined that the path is an absolute path or a relative path: all relative are dot path "starts, the relative path without processing to extract only the absolute path from the starting character and between the elements of the tag label terminator element, the path for the separated absolute address for the first path; and in step S400, we will address a new path, i.e., a second absolute path, previously inserted into the first absolute position on the path to complete the replacement operation; above steps thereafter a similar operation for the entire XML document, the XML file so that the entire Alternatively operations have been completed, i.e. step S301 is further performed in step S300, the whole XML file to find the previous step of the same first path absolute path address 对于整个操作流程都完成的文件,在步骤S500中进行保存,并在步骤S600中将所有涉及到的替换进行记录,生成记录文件。这样对于后续的XML文件,可以直接根据该记录文件进行路径替换,节省时间。 Processes are completed for the entire operation of the file, in step S500, save, and relates to all alternatives recorded in the step S600, the generated log file. For such subsequent XML file, the path may be a direct replacement in accordance with the record file ,save time.

[0025] 考虑到一般的文件名在不同的平台上有相同的表示,即文件索引是相同的,不同的仅为绝对路径中前面部分的路径索引。 [0025] Taking into account the general representation of the same file name, document index is the same on different platforms, an absolute path index different only in the front portion of the path. 因此在进行步骤S300和步骤S400的时候,可以仅提取、替换路径索引部分,以减少替换的工作量。 Thus performing step S300 and step S400, it can extract only, alternate route index portion, to reduce the workload of replacement.

[0026] 如图3所示,为步骤S600中所生成的记录文件,在该记录文件中记录了对XML文件中其中一处的图片引用的绝对路径替换历史。 [0026] As shown in FIG. 3, step S600 is generated record file, a record of the absolute path of the XML file wherein a reference picture is replaced in the recording history file. 第一开发者接收到XML文件的时候,弓丨用的图片的第一绝对路径为“C:\media\l.jpg”;然而在第一开发者所使用的平台上,该图像文件是存放在第二绝对路径“/mnt/Sda2/media/l.jpg”上的,因此,采用了本发明的转换步骤之后,对于同一个图像文件的引用在该XML文件上的引用则转换为“/mnt/sda2/media/1, jpg”,以方便该XML文件在第一开发者的平台上正常显示。 The first developer receiving the XML file, with the first picture bow Shu absolute path is "C: \ media \ l.jpg"; however, on the platform of the first developers to be used, the image file is stored after the second absolute path "/mnt/Sda2/media/l.jpg", and therefore, using the conversion step of the present invention, a reference to a same reference image file is converted to "in the XML file / mnt / sda2 / media / 1, jpg ", to facilitate the XML file displayed properly on the first developer platform. 此后,该XML文件转由第二开发者继续进行编辑,并采用同样的转换步骤。 Thereafter, the XML file transferred from a second developer continue editing, and using the same conversion step. 此时,原先在第一开发者中的第二绝对路径在第二开发者的平台中则变成第一绝对路径。 At this point, the original second absolute path in the first developer in the second developer platform becomes the first absolute path. 若恰好出现两个绝对路径相同,无需更换的情况,也同样将其进行记录,如图3中的第N开发者,以方便该开发者在下一次进行替换时快速找到该路径。 If two same absolute path, without changing situation occurs exactly, it will also be recorded, a first developer N in FIG. 3, to facilitate the next developer to quickly find the path for the replacement.

[0027] 图3所示的记录文件仅针对I个XML文件中的I个图像引用的替换历史,在实际的开发中常常需要对多个XML文件中的多个元素进行替换。 Log file shown in [0027] FIG. 3 only for the I XML file referenced image I history Alternatively, a plurality of multiple elements often necessary to replace the XML file in the actual development. 此时,我们可以依据图3的记录文件将其扩展为数据库。 At this point, we can record files according to Figure 3 will expand its database. 以便支持多文件的多位置转换。 In order to support multi-location multi-file conversion. 在开发者接手进行研发的时候,首先运行该数据库,并对每一个XML文件进行转换,然后再进行研发,并且在研发结束后,更新数据库中的绝度路径的信息。 When the developer to take over research and development, first run the database, and each XML file to convert, and then research and development, and at the end of the development, update information of absolute path in the database.

[0028] 以上仅为本发明具体实施方式,不能以此来限定本发明的范围,本技术领域内的一般技术人员根据本创作所作的均等变化,以及本领域内技术人员熟知的改变,都应仍属本发明涵盖的范围。 [0028] The above are merely specific embodiments of the present invention, not intended to limit the scope of the present invention, one of ordinary skill in the art in accordance with the present creation and alterations made, as well as changes well known to persons skilled in the art, should be the present invention still covers.

Claims (6)

  1. 1.一种XML绝对路径转换方法,其特征在于,包括以下的步骤: 3100、读取乂1^文件; S200、检索XML文件中的元素标签起始符与元素标签结束符; 5300、提取元素标签起始符与元素标签结束符之间的第一绝对路径; S400、将第二绝对路径插入元素标签起始符与元素标签结束符之间; S500、保存XML文件。 An XML absolute path switching method comprising the steps of: 3100, 1 ^ qe read document; S200, retrieve the XML document element start symbol and the tag label terminator element; 5300, extracting element tag start symbol and end element tags absolute path between a first symbol; S400, an absolute path of the second insertion element tag start character and symbol elements between the end of the label; S500, save the XML file.
  2. 2.根据权利要求1所述的XML绝对路径转换方法,其特征在于,所述步骤S300还包括: 5301、提取XML文件中与第一绝对路径相同的绝对路径地址。 2. XML absolute path switching method according to claim 1, characterized in that, further comprising the step S300: 5301, extract the XML file with the absolute path of the first path to the same absolute address.
  3. 3.根据权利要求2所述的XML绝对路径转换方法,其特征在于,所述步骤S400还包括: 将第二绝对路径放入元素标签起始符与元素标签结束符之间。 3. XML absolute path switching method according to claim 2, characterized in that, the step S400 further comprises: a second path into an absolute tag element start symbol and the end symbol elements between the tags.
  4. 4.根据权利要求1所述的XML绝对路径转换方法,其特征在于,还包括S600: 生成记录文件,记录文件记录第一绝对路径与第二绝对路径。 The XML absolute path switching method according to claim 1, characterized by further comprising S600: generating a log file, the log file records a first and a second absolute path absolute path.
  5. 5.根据权利要求4所述的XML绝对路径转换方法,其特征在于,第一绝对路径包括依次排列的第一路径索引和第一文件索引;第二绝对路径包括依次排列的第二路径索引和第二文件索引;第一文件索引与第二文件索引相同;在步骤S300中提取第一绝对路径的第一路径索引,在步骤S400中将第二路径索引放入元素标签起始符与元素标签结束符之间。 The XML absolute path switching method as claimed in claim 4, characterized in that the first absolute path comprises a first path arranged in this order, and a first index file index; second absolute path includes a second path arranged in this order, and the index a second index file; a first file and the second index file index the same; a first path index extracting absolute path in a first step S300, the start code into element tags and tag elements in step S400 in the second path index between the end of the character.
  6. 6.根据权利要求4所述的XML绝对路径转换方法,其特征在于,还包括读取记录文件,依据记录文件中的记录的第一绝对路径与第二绝对路径,对其他XML文件进行绝对路径转换。 The XML absolute path switching method as claimed in claim 4, characterized in that, further comprising reading a file record, according to the first and second absolute path absolute path recorded in the log file, other XML file absolute path conversion.
CN 201310353703 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path CN104376008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201310353703 CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201310353703 CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Publications (1)

Publication Number Publication Date
CN104376008A true true CN104376008A (en) 2015-02-25

Family

ID=52554928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201310353703 CN104376008A (en) 2013-08-14 2013-08-14 Method for replacing XML (extensive markup language) absolute path

Country Status (1)

Country Link
CN (1) CN104376008A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170070A1 (en) * 2001-03-01 2002-11-14 Rising Hawley K. Multiple updates to content descriptions using a single command
CN1584884A (en) * 2003-08-20 2005-02-23 富士通株式会社 Apparatus and method for searching data of structured document
CN101986311A (en) * 2010-11-17 2011-03-16 浙江省电力试验研究院;浙江省电力试验研究院技术服务中心 Method for buffering node elements when rapidly processing large-scale XML file

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170070A1 (en) * 2001-03-01 2002-11-14 Rising Hawley K. Multiple updates to content descriptions using a single command
CN1584884A (en) * 2003-08-20 2005-02-23 富士通株式会社 Apparatus and method for searching data of structured document
CN101986311A (en) * 2010-11-17 2011-03-16 浙江省电力试验研究院;浙江省电力试验研究院技术服务中心 Method for buffering node elements when rapidly processing large-scale XML file

Similar Documents

Publication Publication Date Title
US5553216A (en) Structured database system together with structure definition frame storing document body data
US20050120300A1 (en) Method, system, and apparatus for assembly, transport and display of clinical data
US20060136433A1 (en) File formats, methods, and computer program products for representing workbooks
US7127472B1 (en) Data processing method and data processing device
US20070233456A1 (en) Document localization
US7496230B2 (en) System and method for automatic natural language translation of embedded text regions in images during information transfer
US20090123071A1 (en) Document processing apparatus, document processing method, and computer program product
US20110016429A1 (en) Information processing apparatus, information processing method and computer readable medium
US20060075337A1 (en) Method, system, and computer-readable medium for creating, inserting, and reusing document parts in an electronic document
US20090043824A1 (en) Document creation, linking, and maintenance system
US20030222916A1 (en) Object-oriented processing of tab text
CN101308488A (en) Document stream type information processing method based on format document and device therefor
CN101243439B (en) Markup based extensibility for user interfaces
Edhlund et al. Nvivo 11 essentials
US20080037047A1 (en) Extendable meta-data support in final form presentation datastream print enterprises
US7254593B2 (en) System and method for tracking annotations of data sources
JP2001337994A (en) Thumbnail display system and method and recording medium with processing program therefor recorded therein
US6629101B1 (en) Data processing method and apparatus, and storage medium
CN1588352A (en) Recording method for extendable mark language file repairing trace
CN101271463A (en) Representation method and system of layout file logical structure information
US20060047647A1 (en) Method and apparatus for retrieving data
US20100325539A1 (en) Web based spell check
US20080263518A1 (en) Software documentation manager
US7945541B1 (en) Version set of related objects
US20070118497A1 (en) Linking of identical character strings in differnt files

Legal Events

Date Code Title Description
C06 Publication
C10 Entry into substantive examination