我需要匹配所有这些开始标记:
<p>
<a href="foo">
Run Code Online (Sandbox Code Playgroud)
但不是这些:
<br />
<hr class="foo" />
Run Code Online (Sandbox Code Playgroud)
我想出了这个,并希望确保我做对了.我只抓住了a-z.
<([a-z]+) *[^/]*?>
Run Code Online (Sandbox Code Playgroud)
我相信它说:
/,然后我有这个权利吗?更重要的是,你怎么看?
当我的XML看起来像这样(不xmlns),那么我可以很容易地用XPath查询它/workbook/sheets/sheet[1]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook>
<sheets>
<sheet name="Sheet1" sheetId="1" r:id="rId1"/>
</sheets>
</workbook>
Run Code Online (Sandbox Code Playgroud)
但是当它看起来像这样我就不能
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheets>
<sheet name="Sheet1" sheetId="1" r:id="rId1"/>
</sheets>
</workbook>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我花了一天时间尝试从以下文档中提取一个XML节点,并且无法掌握XML命名空间的细微差别以使其工作.
XML文件很大,总共发布,所以这是我关注的部分:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<XFDL xmlns="http://www.PureEdge.com/XFDL/6.5" xmlns:custom="http://www.PureEdge.com/XFDL/Custom" xmlns:designer="http://www.PureEdge.com/Designer/6.1" xmlns:pecs="http://www.PureEdge.com/PECustomerService" xmlns:xfdl="http://www.PureEdge.com/XFDL/6.5">
<globalpage sid="global">
<global sid="global">
<xmlmodel xmlns:xforms="http://www.w3.org/2003/xforms">
<instances>
<xforms:instance id="metadata">
<form_metadata>
<metadataver version="1.0"/>
<metadataverdate>
<date day="05" month="Jul" year="2005"/>
</metadataverdate>
<title>
<documentnbr number="2062" prefix.army="DA" scope="army" suffix=""/>
<longtitle>HAND RECEIPT/ANNEX NUMBER </longtitle>
</title>
Run Code Online (Sandbox Code Playgroud)
该文件继续存在并且形成良好.我试图从"documentnbr"标签中提取"数字"属性(从底部三个).
我用来执行此操作的代码如下所示:
/***
* Locates the Document Number information in the file and returns the form number.
* @return File's self-declared number.
* @throws InvalidFormException Thrown when XPath cannot find the "documentnbr" element in the file.
*/
public String …Run Code Online (Sandbox Code Playgroud) 我试图通过使用现有的本体从XML文件中提取RDF三元组.我正在使用Java,并且可以使用XPath从XML和Jena中提取数据来读取和写入RDF文档和本体.如何根据现有本体从XML中提取相关的三元组?
我试图修改PHP_JPEG_Metadata_Toolkit中的代码,以便我可以使用PHP正确读取和写入jpeg文件的XMP数据.目前,由于XMP块,jpeg文件(由Toolkit保存时)会给Adobe Photoshop和Bridge带来错误.
我有两种方法可以看到Photoshop使用的XMP RDF架构.第一个是Photoshop实际上在jpg中保存的内容以及我要导入的内容.Photoshop对所有内容使用单个rdf:Description块.它会在块本身内抛出许多模式标识符(url)PLUS会为许多元数据字段添加值.接下来是Dublin Core,Photoshop,Iptc4xmpCore等的标记块,但所有标记块都集中在一个Description标记中.
第二个是在Photoshop"文件信息"中显示的整齐格式化的元数据,它遵循RDF 的XMP文档(其中指出"按照惯例,来自给定模式的所有属性,只有该模式,列在单个rdf:Description元素中".)
通过按照Photoshop实际发送的示例(一个rdf下的所有内容:描述),我已经能够通过Toolkit编辑错误来解决问题.
两个问题:任何想法为什么Photoshop保存XMP元数据不同于它在程序中显示的内容?并且......为什么我应该花时间将输出格式化为RDF规范,当它在一个rdf中很好地混合在一起时:描述?我是新手,所有这些,所以任何指导将不胜感激.
这些示例已经过编辑,因此您可以更轻松地查看格式差异 - 请原谅两者之间因编辑而导致的内容差异.
这是我实际从Photoshop(编辑)收到的内容:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmpMM:DocumentID="xmp.did:8808E8B6139411E3A70AB29CEEC8FF6C"
xmpMM:InstanceID="xmp.iid:0071BBEF4517E311BCBCC2DF868D188C"
xmpMM:OriginalDocumentID=""
xmp:CreatorTool="(PHP JPEG Metadata Toolkit v1.12)"
xmp:MetadataDate="2013-09-06T15:44:49-07:00"
xmp:ModifyDate="2013-09-06T15:44:49-07:00"
xmp:CreateDate="2013-09-06T15:22:46-07:00"
xmpRights:Marked="True"
xmpRights:WebStatement="MY WEB ADDRESS"
Iptc4xmpCore:IntellectualGenre=""
photoshop:Instructions="OOOInstructions"
photoshop:Headline="OOOHeadline"
photoshop:CaptionWriter="MY NAME"
dc:format="image/jpeg">
<xmpMM:DerivedFrom stRef:instanceID="6B5F4850BB0819F254E40401F67ACAC9"
<stRef:documentID="6B5F4850BB0819F254E40401F67ACAC9"/>
<xmpRights:UsageTerms>
<rdf:Alt>
<rdf:li xml:lang="x-default">MY INFO HERE</rdf:li>
</rdf:Alt>
</xmpRights:UsageTerms>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">OOODescription
</rdf:li>
</rdf:Alt>
</dc:description>
</rdf:Description>
</rdf:RDF>
Run Code Online (Sandbox Code Playgroud)
这是Photoshops格式很好的视图(已编辑)
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#">
<xmpMM:DocumentID>xmp.did: … …Run Code Online (Sandbox Code Playgroud) 我有两个RDF文件:
我想将它们合并到一个文件中,例如purl_foaf.rdf.我在Java工作; 我怎么能和耶拿一起做这件事?