OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A simple guy with a simple problem



 I know this thread is really talking about some problems with the
 concepts of "sameness" and what processing is, but thought I'd throw in
 an attempt at a solution.  I note that the foo.dtd is available, so we
 might as well use it.
 
 I'm sure that there are all kinds of problems with it - in particular
 I'm not sure what to do with the STUFF that crosses the CDATA or entity
 boundaries - it's a bit hard to preserve the boundary and make the
 change - I have preserved boundaries with the CDATA, but resolved and
 changed the entities.  That said, though, it seems to me that lacking
 further definition of what is meant by "sameness" and of the particular
 situation Bob is in, this solution seems to work quite well, and wasn't
 hard to put together.  Which probably means that I'm missing
 something...
 
 -- 
 David Mc Nally  SGML Analyst/Programmer
 Matthew Bender & Co, Inc.
 (212)448-2585 fax:(212)448-2469
 
 foo.xom for Omnimark 5 (using the now deprecated context-translate model
 for brevity):

 
 context-translate with xml
 
 global switch sw-dtd-is-done initial {false}
 global stream s-doctype initial {""}
 
 define stream function stuff-repl (value stream s-stream) as
 	local stream s-out
 	open s-out as buffer
 	using output as s-out
 	repeat scan s-stream
 		match "STUFF"
 			output "stuff"
 		match any=>whatever
 			output whatever
 	again
 	close s-out
 	return s-out
 
 ;........................................................
 
 ; if need be, put find rules in here to match entity declarations in the 
 ; internal subset, and do the replacement
 ; Could also insert markers of where entities occurred
 
 find (any-text+ "%n") => whatever when not sw-dtd-is-done
 	set s-doctype to s-doctype || whatever
 	output whatever
 
 ;........................................................
 
 dtd-start
 	deactivate sw-dtd-is-done
 
 dtd-end
 	activate sw-dtd-is-done
 	output s-doctype
 
 sgml-comment when sw-dtd-is-done
 	output "<!--%c-->"
 
 marked-section cdata
 	output "<![CDATA["
 	output stuff-repl("%c")
 	output "]]>"
 
 element #implied
 	local stream att
 	output "%n<%q"
 	; output attributes, replacing STUFF with stuff
 	repeat over specified attributes as ThisAttribute
 		output " "
 		set att to key of attribute ThisAttribute
 		output "%g(att)"
 		output "="
 		output stuff-repl("%"%v(ThisAttribute)%"")
 	again
 	; output defaulted attributes that contain STUFF, replacing STUFF
with
 stuff
 	repeat over attributes as ThisAttribute
 		do when attribute ThisAttribute is defaulted 
 			and attribute ThisAttribute matches unanchored
"STUFF"
 			output " "
 			set att to key of attribute ThisAttribute
 			output "%g(att)"
 			output "="
 			output stuff-repl("%"%v(ThisAttribute)%"")
 		done
 	again
 	do when content is empty
 		output "/>"
 	else
 		output ">"
 		output stuff-repl("%c")
 		output "</%lq>"
 	done
  
 
 
 The output I get is: 
 
 C:\Temp>omnimark -s foo.xom foo.xml
 OmniMark C/VM 5.1
 Copyright (c) 1988-1999 by OmniMark Technologies Corporation.
          <?foo bar?>
          <!DOCTYPE foo SYSTEM "foo.dtd" [
          <!ENTITY bar "this is some STUFF">
          ]>
 
 <FOO>
 <LIT TEXT="hello">         <![CDATA[This is literal
          stuff]]>
          </lit>
 <LIT TEXT="stuff">         this is some stuff
          </lit></foo>
 
 
 C:\Temp>omnimark -s foo.xom foo2.xml
 OmniMark C/VM 5.1
 Copyright (c) 1988-1999 by OmniMark Technologies Corporation.
 <?foo bar?>
 <!DOCTYPE foo SYSTEM "foo.dtd" [
 <!ENTITY bar "this is some ST">
 <!ENTITY biz "UFF">
 ]>
 
 <FOO>
 <LIT TEXT="hello"><![CDATA[This is literal
 STU]]><![CDATA[ FF]]></lit>
 <LIT TEXT="stuff">this is some stuff</lit></foo>