Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pml-haters [2007/05/16 03:19] bojar odkaz na Honzovu ukazku validace |
pml-haters [2007/06/05 06:35] (current) bojar jen formatovani |
||
---|---|---|---|
Line 6: | Line 6: | ||
Links to additional tools are at the bottom of the page. | Links to additional tools are at the bottom of the page. | ||
+ | |||
+ | I strongly recommend [[http:// | ||
===== In Spite of some Common Assumptions... ===== | ===== In Spite of some Common Assumptions... ===== | ||
Line 12: | Line 14: | ||
Please strongly prefer SAX-based tools to DOM-based tools. | Please strongly prefer SAX-based tools to DOM-based tools. | ||
- | |||
===== Validation ===== | ===== Validation ===== | ||
- | Given a PML file, how do I validate it? I always forget... Please provide me with the one-liner to do the validation. | + | Given a PML file, how do I validate it? |
- | See [[user: | + | For most purposes, a libxml2 (DOM) based validator |
+ | < | ||
+ | |||
+ | For huge files, use< | ||
+ | Both scripts have decent user documentation. See inside the scripts if interested in the implementation details. | ||
===== XSH Won't Work: Blame XML Namespaces ===== | ===== XSH Won't Work: Blame XML Namespaces ===== | ||
Line 40: | Line 45: | ||
The reason why '' | The reason why '' | ||
- | < | + | < |
$f/>cd pml:tdata | $f/>cd pml:tdata | ||
$f/ | $f/ | ||
</ | </ | ||
+ | |||
+ | Hint: add the regns command to your ~/.xsh2rc. | ||
You will have to write the '' | You will have to write the '' | ||
Most probably you'll still face problems when accessing attributes of XML elements, because namespacing rules apply differently to attributes and elements. You'll need to read XML (Namespaces) specification. | Most probably you'll still face problems when accessing attributes of XML elements, because namespacing rules apply differently to attributes and elements. You'll need to read XML (Namespaces) specification. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
===== Number of Sentences ===== | ===== Number of Sentences ===== | ||
Line 64: | Line 64: | ||
This XPath would quickly give you the number of sentences: | This XPath would quickly give you the number of sentences: | ||
- | < | + | < |
</ | </ | ||
Line 73: | Line 73: | ||
< | < | ||
| xsh -I - -C "regns pml http:// | | xsh -I - -C "regns pml http:// | ||
+ | </ | ||
+ | |||
+ | or just the following, if you have the regns command in your ~/.xsh2rc: | ||
+ | |||
+ | < | ||
+ | | xsh -I - -C " | ||
</ | </ | ||
Line 88: | Line 94: | ||
</ | </ | ||
+ | Here is a one-liner in Perl that does not load the whole file into memory: | ||
+ | < | ||
+ | </ | ||
===== Restricting a Suite of PML Files to Contain only a Specific Sentence ===== | ===== Restricting a Suite of PML Files to Contain only a Specific Sentence ===== | ||
Line 97: | Line 105: | ||
How do I create a suite of files with just the problematic sentence 345, i.e. files test-w.xml, test-m.xml, test-a.xml and test-t.xml, all properly referenced? A XML-Reader based script by Petr Pajas demonstrates that: | How do I create a suite of files with just the problematic sentence 345, i.e. files test-w.xml, test-m.xml, test-a.xml and test-t.xml, all properly referenced? A XML-Reader based script by Petr Pajas demonstrates that: | ||
- | < | + | < |
</ | </ | ||
Line 107: | Line 115: | ||
[[http:// | [[http:// | ||
- |