Aşağıda iki XML (SVG) belgesine sahibim. Orijinal Adobe Illustrator'da açılmış ve yeni ihraç edilmiştir. Hepsi bu.Neden XPath ifadesi Illustrator tarafından oluşturulan XML'de başarısız oluyor?
Fark, XPath ifadesinin dışa aktarılan dosyayla çalışamamasıdır! xmllint --xpath '/svg' ill.svg
sadece XPath set is empty
verir oysa
xmllint --xpath '/svg' org.svg
<svg>
elemanın tüm içeriğini verir.
DOCTYPE
hariç, iki dosya arasında anlamlı bir fark bulamıyorum, ancak el ile ekleme yapmak fark yaratmaz.
org.svg
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg viewBox = "0 0 800 600" version = "1.1">
<!-- Oslo -->
<path
id = "Oslo_0"
fill = "green"
stroke = "white" stroke-width = "1"
d = "M294.816,483.766l0.71,1.432l3.134,4.696c0.528,0.793,0.701,1.776,0.47,2.701l-0.193,0.793 c0.659,0.131,1.29,0.391,1.77,0.874l0.435,0.417l1.049,0.502l3.259,1.569c1.294,0.518,1.551,1.756,1.551,3.146v1.786l1.96,3.442 c0.299,0.741,0.522,1.541,0.268,2.297l-0.269,1.359l0.485,0.119l0.408,0.702L311.49,511h0.6h2.598h0.947l-1.272-6.497 c-0.105-0.525-0.179-1.427-0.03-1.943l1.435-5.858l-0.806-0.671L314,495.032v-0.824c0-0.892,1.77-1.751,2.4-2.383l1.436-0.351 l-0.061-1.118l-0.781-0.433l-0.322-0.211l-4.858-3.25c-0.575-0.384-1.002-0.918-1.256-1.563l-2.469-4.064 c-0.158-0.396-1.089-0.826-1.089-1.252v-2.102l0.287-2.98l-1.477-2.634c-0.224-0.301-0.133-0.605-0.25-0.963l-1.164-2.435 c-0.118-0.357-0.396-0.695-0.396-1.073v-0.346l-2.684-1.15c-0.335-0.168-0.577,0.64-0.844,0.376L300.125,467h-3.611l0.986,2.668 c0.297,1.207-0.083,2.15-1,2.989l-6.98,6.237l4.508,3.928C294.35,483.103,294.624,483.383,294.816,483.766z"
/>
</svg>
ill.svg Eğer gözden kaçan olduğunuz bir çok anlamlı bir fark vardır
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="612px" height="792px" viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">
<path id="Oslo_0" fill="#008000" stroke="#FFFFFF" d="M225.5,536.6l0.5,1.1l2.4,3.6c0.4,0.6,0.5,1.4,0.4,2.1l-0.1,0.6
c0.5,0.1,1,0.3,1.4,0.7l0.3,0.3l0.8,0.4l2.5,1.2c1,0.4,1.2,1.3,1.2,2.4v1.4l1.5,2.6c0.2,0.6,0.4,1.2,0.2,1.8l-0.2,1l0.4,0.1l0.3,0.5
l1.3,1.1h0.5h2h0.7l-1-5c-0.1-0.4-0.1-1.1,0-1.5l1.1-4.5l-0.6-0.5l-0.7-0.8v-0.6c0-0.7,1.4-1.3,1.8-1.8l1.1-0.3l0-0.9l-0.6-0.3
l-0.2-0.2l-3.7-2.5c-0.4-0.3-0.8-0.7-1-1.2l-1.9-3.1c-0.1-0.3-0.8-0.6-0.8-1v-1.6l0.2-2.3l-1.1-2c-0.2-0.2-0.1-0.5-0.2-0.7l-0.9-1.9
c-0.1-0.3-0.3-0.5-0.3-0.8v-0.3l-2.1-0.9c-0.3-0.1-0.4,0.5-0.6,0.3l-0.3,0.6h-2.8l0.8,2c0.2,0.9-0.1,1.6-0.8,2.3l-5.3,4.8l3.4,3
C225.2,536.1,225.4,536.3,225.5,536.6z"/>
</svg>
Aha! Çok iyi lekeli! Dosyayı düzenlemeden bunu nasıl sorgularım? – oligofren
@oligofren İşte bazı yollar: [[1] (http://stackoverflow.com/questions/22599627/xmllint-xmlns-on-a-non-root-xml-element)], [[2] (http: //stackoverflow.com/questions/8264134/xmllint-failing-to-properly-query-with-xpath)] – har07
Teşekkürler, @ har07. Cevap için referans eklendi. – kjhughes