[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: A simple guy with a simple problem

  • From: "McNally, David J. (LNG-MBC)" <David.J.McNally@b...>
  • To: "'xml-dev@l...'" <xml-dev@l...>
  • Date: Fri, 16 Mar 2001 11:34:58 -0500

omnimark 5
 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>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.