<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>So far the discussion is around whether the xml is well-formed.</div><div>Once you get that working, then you need to make sure it is valid wrt the OSIS schema.</div><div><br></div><div>There's an old tool that will convert sgml to well-formed xml. I think it was James Clark's "sx". I've used it successfully on initial conversions and getting something that will work within xml tools.</div><div><br></div><div>Finally, OSIS has the notion of milestones for start and end elements. There are semantic rules regarding this that cannot be checked by standard xml tools. Osis2mod tries to handle this. When you get to that point, I can help unravel the logging options.</div><div><br></div><div>The purpose of milestoned elements is to allow for two competing document models to be in the same xml document: BSP and BCV (names we've given it here and in the wiki).</div><div><br></div><div>We recommend using BSP (book, chapter, section, paragraph, poetry, lists to all be containers, not milestoned) and verse elements be milestoned.</div><div><br></div><div>Note, the OSIS manual says that if you have one element milestoned, then all other elements with the same tag name have to be milestoned. Practically speaking, this does not matter. SWORD and JSword don't care. Having verses milestoned only if necessary is probably a better way to create a good XML document. Start out with all of them as containers and each place where that causes a problem, either fix the xml or if otherwise correct, convert to milestoned verses.</div><div><br></div><div>Generally speaking these BSP elements should not start just inside or at the end of a verse. Rather they should be between verse elements or within the text. When they are placed just after the verse start, they often will cause the verse number to be orphaned. When they are placed just before the verse end, then it is generally not noticeable (just bad form).</div><div><br></div><div>Quotes will create the biggest grief in the above. They often cross boundaries. Certainly, the beatitudes does, starting in one chapter and ending a couple of chapters later. For this reason, using the milestoned version is necessary.</div><div><br></div><div>If you're document follows some simple rules (some required by xml, others simplifications), then checking nesting is a simple matter of having a push/pop stack of elements. The simple rules:</div><div>1) All attributes when present have quoted values.</div><div>2) All entities are properly formed and used when needed. Also,&nbsp;&lt; and &gt; are not in attribute values.&nbsp;</div><div>3) Tags are marked with &lt; ... &gt;, &lt;/ ... &gt;, or &lt; ... /&gt;. and now new lines between &lt; and &gt;.</div><div><br></div><div>If this is true then a simple perl script can be written to find the problems in the file:</div><div>Look for &lt; ... /&gt; and skip them. They cause no problems.</div><div>Look for &lt; xxx ... &gt; and push the tag name along with its location in the file on to the stack.</div><div>Look for &lt; xxx /&gt;, compare xxx to the top element on the stack. If it doesn't match, then it causes an error.</div><div>When you get to the end of the document and the stack is not empty, then the elements on the stack are not closed properly.</div><div><br></div><div>Printing out the stack (elements and locations) would help find what the problem is.</div><div><br></div><div>For example:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if xxx is deeper in the stack, then there is a problem with nesting. Look at all the elements above the xxx on the stack for problems.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if it is not in the stack, then the element was not started prior to that point or it may have been ended twice.</div><div><br></div><div>Here is a simple perl script (that I wrote), which doesn't do that, but could be adapted to do it. This creates a histogram/dictionary of tag and attribute names.</div><div><br></div><div><div>#!/usr/bin/perl</div><div><br></div><div>use strict;</div><div><br></div><div>my %tags = ();</div><div>my %attrs = ();</div><div>while (&lt;&gt;)</div><div>&nbsp; {</div><div>#print;</div><div>&nbsp; &nbsp; # While there is a tag on the line</div><div>&nbsp; &nbsp; while (/&lt;[^\/\s&gt;]+[\/\s&gt;]/o)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; # While there is an attribute in the tag</div><div>&nbsp; &nbsp; &nbsp; while (/&lt;[^\/\s&gt;]+\s+[^\=\/\&gt;]+=\"[^\"]+\"/o)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;# remove the attribute</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;s/&lt;([^\/\s&gt;]+)\s+([^\=\/\&gt;]+)(\="[^\"]+\")(.*)/&lt;$1 $4/o;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;my ($t, $a, $v, $r) = ($1, $2, $3, $4);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;$attrs{"$t.$a"}++;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>&nbsp; &nbsp; &nbsp; # remove the tag</div><div>&nbsp; &nbsp; &nbsp; s/&lt;([^\/\s&gt;]+)[\/\s&gt;]//o;</div><div>&nbsp; &nbsp; &nbsp; $tags{$1}++;</div><div>#print("do next tag on line\n");</div><div>&nbsp; &nbsp; }</div><div>#print("do next line\n");</div><div>&nbsp; }</div><div><br></div><div>foreach my $tag (sort keys %tags)</div><div>&nbsp; {</div><div>&nbsp; &nbsp; print("$tag\n");</div><div>&nbsp; }</div><div><br></div><div>foreach my $attr (sort keys %attrs)</div><div>&nbsp; {</div><div>&nbsp; &nbsp; print("$attr\n");</div><div>&nbsp; }</div></div><div><br></div><div>Hope this helps,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><br><div><div><div>On Sep 21, 2012, at 10:52 AM, Andrew Thule &lt;<a href="mailto:thulester@gmail.com">thulester@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks everyone for suggestions. &nbsp;I'll give them all a try.&nbsp;<div><br></div><div>That said, the emacs recommendation is nearly a religious conversion recommendation. &nbsp;(I'm on the vi side of the vi verses emacs debate. &nbsp;I suppose as long as it doesn't kill me I should give it a try, though I'm not certain what impact it will have on the health of my soul ... :D )</div>
<div><br></div><div>~A</div><div><br><br>On Thursday, September 20, 2012, Daniel Owens  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I use jEdit with the XML plugin installed. I find it helps me find problems fairly easily.<br>

<br>
Daniel<br>
<br>
On 09/20/2012 05:26 PM, Greg Hellings wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There are a number of pieces of software out there that will<br>
pretty-print the XML for you, with indenting and whatnot. Overly<br>
indented for what you would want in production but decent for<br>
debugging mismatching nesting and the like.<br>
<br>
For example, 'xmllint --format' will properly indent the file, etc. I<br>
don't know how it will handle poorly formed XML.<br>
<br>
GUI editors can do wonders as well. On Windows I use Notepad++ and<br>
manually set it to display XML. gEdit and Geany - I believe - both<br>
support similar display worlds. And there are some plugins for Eclipse<br>
that might handle what you need as well.<br>
<br>
--Greg<br>
<br>
On Thu, Sep 20, 2012 at 4:19 PM, Karl Kleinpaste &lt;<a>karl@kleinpaste.org</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Andrew Thule &lt;<a>thulester@gmail.com</a>&gt; writes:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One of my least favour things is finding mismatched tags in OSIS.xml files<br>
Has anyone successfully climbed this summit?<br>
</blockquote>
XEmacs and xml-mode (and font-lock-mode). &nbsp;M-C-f and M-C-b execute<br>
sgml-forward-element and -backward-. &nbsp;That is, sitting at the beginning<br>
of &lt;tag&gt;, M-C-f (meta-control-f) moves forward to the matching &lt;/tag&gt;,<br>
properly handling nested tags.<br>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a>sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a>sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
<br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a>sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote></div><span></span>
_______________________________________________<br>sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org">sword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>Instructions to unsubscribe/change your settings at above page</blockquote></div><br></div></body></html>