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/25 01:49] bojar odkaz na pekny clanek se sirsim rozhledem |
pml-haters [2007/06/05 06:35] (current) bojar jen formatovani |
||
---|---|---|---|
Line 14: | 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? |
+ | |||
+ | For most purposes, a libxml2 (DOM) based validator | ||
+ | < | ||
- | See [[user: | + | 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 42: | 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 66: | Line 64: | ||
This XPath would quickly give you the number of sentences: | This XPath would quickly give you the number of sentences: | ||
- | < | + | < |
</ | </ | ||
Line 75: | 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 90: | 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 99: | 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 109: | Line 115: | ||
[[http:// | [[http:// | ||
- |