f



embedding xml in xml as non-xml :)

Hi all,

	I have an application that logs in xml.

	Assume <xmlLog></xmlLog>. In this element the app logs anything it gets 
from foreign hosts. Now if the host sends xml data, the structure of the 
document changes. ie. <xmlLog><somTag></somTag></xmlLog>.  This will 
cause problems with my log reader, because it assumes that <xmlLog/> 
contains non-xml data.

	My question is, is there a way to treat the data in the <xmlLog/> 
element as non xml data. Something I can do that would treat anything 
this element contains as a literal?

	Any help or suggestions would be greatly appreciated.



Regards,


Mark
0
mark6215 (9)
9/14/2004 4:51:39 AM
comp.text.xml 8781 articles. 0 followers. Post Follow

5 Replies
1646 Views

Similar Articles

[PageSpeed] 47

Mark Van Orman <mark@icsaccess.com> wrote:
> Hi all,
> 
>         I have an application that logs in xml.
> 
>         Assume <xmlLog></xmlLog>. In this element the app logs
>         anything it gets from foreign hosts. Now if the host sends xml
>         data, the structure of the document changes. ie.
>         <xmlLog><somTag></somTag></xmlLog>.  This will cause problems
>         with my log reader, because it assumes that <xmlLog/> contains
>         non-xml data.
> 
>         My question is, is there a way to treat the data in the
>         <xmlLog/> element as non xml data. Something I can do that
>         would treat anything this element contains as a literal?
> 
>         Any help or suggestions would be greatly appreciated.

Modify your "log reader".  If remote can send any ASCII, then why does
log reader assume a particular format?  '<somTag></somTag>' is ASCII
string to me.

-- 
William Park <opengeometry@yahoo.ca>
Open Geometry Consulting, Toronto, Canada
0
opengeometry (485)
9/14/2004 5:12:00 AM
On Mon, 13 Sep 2004 23:51:39 -0500, Mark Van Orman
<mark@icsaccess.com> wrote:

>In this element the app logs anything it gets from foreign hosts. 

Your problem is to map "input" to well-formed character data according
to the rules of
http://www.w3.org/TR/2004/REC-xml11-20040204/#syntax

This is a task as old as computer programming with input files. There
are several rechniques to solve it, broadly by "escaping" or by
"wrapping"


Your example of
>    <xmlLog><somTag></somTag></xmlLog>
is quite easy, and could indeed be stored and read back, then treated
as ASCII.

However a foreign host that sends "<notATag<><>>" will break things,
because 
     <xmlLog><notATag<><>></xmlLog>
isn't well-formed XML and so parsers will choke on it.


The main problem is to handle the mapping of arbitrary characters into
"character data"  (this is a term carefully defined in the XML spec).

The "escaping" way to do this is quite simple, and can be done with a
handful of character substitutions (from the XML spec):

:>The ampersand character (&) and the left angle bracket (<) MUST NOT
:> appear in their literal form, [...]  they MUST be escaped using
:> either numeric character references or the strings "&amp;" and "&lt;"
:> respectively. The right angle bracket (>) MAY be represented using
:> the string "&gt;", and MUST, for compatibility, be escaped using
:> either "&gt;" or a character reference when it appears in the string
:> "]]>" in content, 

So your example of 
    <xmlLog><somTag></somTag></xmlLog>
becomes 
    <xmlLog>&lt;somTag&gt;&lt;/somTag&gt;</xmlLog>


You could also use a "CDATA section", which would be the "wrapping"
approach. This takes the dubious input content and places it between
two markers that say "Between these points is CDATA, not XML markup"

The markers are      <![CDATA[     and     ]]>

Your example of 
    <xmlLog><somTag></somTag></xmlLog>
becomes
    <xmlLog><![CDATA[<somTag></somTag>]]></xmlLog>

be warned that you'll still need escaping in case the input contains a
copy of the end marker!   (read the XML spec, or ask again)



Second problem is to define "input". This is important because in
today's world we're really having to face up to internationalization,
character sets and encodings.  It's likely that you can redefine input
from "anything" to "anything that is in UTF-8", which will make your
life easier, but be aware you _have_ made a deliberate choice here.

It's OK to write code that breaks in Japanese - just be aware that
you've done so, and know what would need changing if you needed to
remedy this.


You'll find that RSS has this same problem when embedding HTML content
within it.  Some RSS versions handle this better than others, and
there's an excellent overview here
http://diveintomark.org/archives/2004/02/04/incompatible-rss

-- 
Smert' spamionam
0
dingbat (860)
9/14/2004 11:15:30 AM
Andy Dingley wrote:


> It's OK to write code that breaks in Japanese - just be aware that
> you've done so, and know what would need changing if you needed to
> remedy this.
> 
Andy,

	Why would code break only in Japanese and why is that ok?

Regards,
Kenneth
0
9/14/2004 12:51:49 PM
On Tue, 14 Sep 2004 12:51:49 GMT, Kenneth Stephen
<marvin.the.cynical.robot@gmail.com> wrote:

>	Why would code break only in Japanese and why is that ok?

That's just as an example.  Most European-written XML code fails in
CJKV countries (China, Japan, Korea, Vietnam).  Most American-written
XML fails in France  Just look how many RSS feeds choke when they meet
�, or more usually &eacute; with the entity having been defined.

XML _itself_ (and the major tools) are very good at supporting a wide
range of character sets and encodings, but there are rules you have to
follow. For most _applications_, coders don't bother to do this.  If
you _know_ your app will never receive something outside ASCII, then
that's all you need - but you should still be aware of what you've
built.

-- 
Smert' spamionam
0
dingbat (860)
9/14/2004 3:32:23 PM
In article <3fjdk0lb6hmuv12ujbk9h141slrrasciui@4ax.com>,
Andy Dingley  <dingbat@codesmiths.com> wrote:

[...]

% The markers are      <![CDATA[     and     ]]>
% 
% Your example of 
%     <xmlLog><somTag></somTag></xmlLog>
% becomes
%     <xmlLog><![CDATA[<somTag></somTag>]]></xmlLog>
% 
% be warned that you'll still need escaping in case the input contains a
% copy of the end marker!   (read the XML spec, or ask again)

You don't need escaping so much as you need to end and restart the
CDATA section

<xmlLog><![CDATA[<somTag><![CDATA[with a CDATA section]]>]]><![CDATA[</somTag>]]></xmlLog>

The first ]]> ends the first CDATA section. The second is data.
-- 

Patrick TJ McPhee
East York  Canada
ptjm@interlog.com
0
ptjm (515)
9/15/2004 5:57:36 AM
Reply:

Similar Artilces:

XML to XML
I have a gnucash file that I'm trying to transform into an identical XML file without the invoices. I've been at this for a while now. The gnucash file is in XML and the element I'm looking into is: <gnc:transaction> I want to ignore those that contain <slot:key>gncInvoice</slot:key> which is a child of slot which is a child of slots which is a child of transactions. Any help you're willing to provide would be greatly appreciated. Thanks. Classic application for XSLT. Start with the identity transformation, then add a template which matches the ones yo...

To XML or not to XML?
Ok, it has been a while since I've needed to make an involved web page. Coming back on the scene now is a bit confusing, what with all the cool stuff to use like XML, PHP, MySQL, etc... So here is my question. I'm in search of a good dynamic way to generate web pages which separates content from presentation. I am seeking to create a web site that, to put it succinctly, has a list of users and sets of information corresponding to each user. I am familiar with how to do this using PHP, MySQL, and regular old HTML. I maintain the user database in MySQL and dynamically present it and th...

XML or not XML?
I am developing a simple MySQL database editor, and am looking into creating an PHP/AJAX app as the GUI. A lot of this in new ground, and much more is dusting off things I haven't used in a while. My question though involves whether or nor to employ XML. I did some XML a few years back, but don't typically bother anymore. As I see it XML is great when I need to have an app with a standard data presentation that other developers can easily interface. I.E. like a bank statement that may feed a variety of applications developed by a variety of clients. However, if I am develo...

Non-XML tagged value text to XML
I would like to use XSLT to translate some tagged value text to XML elements like this: Input Doc: <data>x=1.234 y=ABC z="Hello World"</data> Output Doc: <x>1.234</value> <y>ABC</y> <z>&quot;Hello World&quot;</z> Is XSLT up to the task? What would it look like? Most of the XSLT string processing code I've seen looks very verbose - can't be too efficient. mikea_59 wrote: > I would like to use XSLT to translate some tagged value text to XML > elements like this: > > Input Doc: > > <data>...

embedding xml in xml as string
I have an xml format for creating a database; lets say a fragment looks like this: <insertValue type="int">7</insert> <insertValue type="string">Hello everyone</insert> now I have a document I am transforming into this format using XSLT: <nDwarves>7</nDwarves> <snowWhiteSays>Hello everyone</snowWhiteSays> <groupReply><possibleReplies replyTo="greeting">hello</possibleReplies> <possibleReplies replyTo="workSignal">hi ho, hi ho</possibleReplies> </groupReply> My pro...

Cocoon XML to XML
Hello. I want t know if it's possible to use cocoon to run xml to xml pipeline without publishing anyelse, just pipeling ? Has somebody tried this ? Thanks ! 8:0) Cram TeXeD -- "La r�alit�, c'est ce qui refuse de dispara�tre quand on a cess� d'y croire." (Philip K.Dick) <http://texed75.free.fr> ...

XML to Canonical XML
I'm trying to find a Ruby package that will convert valid XML into canonical XML. I found the genx4r gem, but that just generates canonical XML. Any pointers appreciated. Gary Wright On Feb 12, 2008 11:47 AM, Gary Wright <gwtmp01@mac.com> wrote: > I'm trying to find a Ruby package that will convert valid XML into > canonical XML. > Define "canonical XML" James [Note: parts of this message were removed to make it a legal post.] http://www.w3.org/TR/xml-c14n On Feb 12, 2008 10:51 AM, James Britt <james.britt@gmail.com> wrote: > On Feb 12, ...

Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser)
Hello Usenet. I'm subject to some confusion with XML and UTF8. I'm working with XML-Simple and I try to decode some XML with with german umlauts (ISO-8859-1). The first XML line declared the encoding correct (see code below). But I'm getting different results using XML-Simple with the default XML parser named XML::Sax and a second parser named XML::Parser. The following code tries to decode the mini XML file and prints the UTF8 flags of the resulting strings. Can someone run this code on his machine and post the results? Thanks. The results on my machine are this: ���ä...

XML to XML Transformation
I was thrust into XML about 2 weeks ago and don't know much yet. From another department in the corp I am receiving an XML file which concatenates nodes all on one line i.e. <car><make>ford</make><color>red</color><year>2001</year></car><car><make><mb> etc. etc. etc. Some lines are over 300 characters long. I need to translate this spagetti XML into something which is humanly readable. I probably need to use XSL however I'm not sure what I need to do. Any help will be much appreciated. "Will" <william...

xml from 2 xml
Hi to everybody, would I like to create a consequential xml from the elaboration of two files xml using xslt, but is it possible to give in input to a trasform 2 files xml? thanks for the possible answers I have already found from me the answer: the function document('file2.xml') matatu ha scritto: > Hi to everybody, > > would I like to create a consequential xml from the elaboration of two > files xml using xslt, but is it possible to give in input to a trasform > 2 files xml? > > thanks for the possible answers ...

[XML] Is there an XML group?
Hi, I've typed an XML source which calls a CSS source, the result should be a page displayed in IE6, instead I see the XML source. That's pretty logical since there a no XHTML tags for IE6 to interpret. I'm looking for a discussion group like'comp.lang.xml' but I can't find one. Please help me. The first task is to see the Blue Jay. universalbitmapper wrote: > I'm looking for a discussion group like'comp.lang.xml' but I can't find > one. There's a comp.text.xml, which might be what you're looking for. Note that I don't read it,...

XML to XML conversion
Hello, I vageuly remember a standard that allowed for an XML document using one tag vocabulary to be translated to a diffirent XML document using a diffirent tag vocabulary using the information provided in a kind of dictionary XML pointed to in an URL present in the original XML file. I am very interested in trying it out for various applications, but I can't find anything on the internet about it, since I don't remember it's name, only the general appearance. Can anyone help me with this? What I remember, approximately: The idea is that you have one XML file, in which th...

Off Topic - Databindings and XML
Dear Group First of all, my apologies for posting here. I tried the MS groups but they're so useless. As some of you work with ASP.NET and XML I wondered if you have come across this and can give me some advice as this group is the only reliable source for an answer. Again, my apologies for posting it here. I wonder if I do something wrong and whether this is possible at all. Any hint is greatly appreciated. I have a XML file bound to a Treeview. The treenodes Text/Value properties bind and populate fine if I set them to an attribute of the XML tag. What I would like to do however is s...

handling xml embedded within xml
I have a log file within which is contained a dump of an xml message .... rubbish ///asd laksj aslf <nif_DEBUG time="Fri, 16 May 2008 13:40:17, 330"> <?xml version="1.0" encoding="UTF-8"?> <ns> <PDQ Lang="fr-FR" ID="XM;1928">content</PDQ> </ns> </nif_DEBUG> ... more junk .... then more xml """) This example is of course a summary. I want to write a streaming filter which will throw out all the junk and just return a series of nice strings of each complete xml message. Ideally I als...

Web resources about - embedding xml in xml as non-xml :) - comp.text.xml

Whitney embedding theorem - Wikipedia, the free encyclopedia
), if m > 0 . This is the best linear bound on the smallest-dimensional Euclidean space that all m -dimensional manifolds embed in, as the real ...

Improved Embedding Tools: Embedded Video Player API and oEmbed support
Launch of embedded video API and oEmbed support for facebook videos and posts

Instagram adds web embedding, makes sharing content on the web easier
... its platform beyond its mobile applications. Today, the photo sharing application has made it easier to share photos and videos with web embedding. ...

School transforms a generation by embedding Indigenous culture into its curriculum
From Indigenous dolls in the childcare centre to a discussion of the treatment of Adam Goodes, embedding Indigenous culture into the curriculum ...


Apple uploads individual iPhone 6 and Apple Watch promo videos to YouTube for your embedding pleasure ...
... iPhone 6 , and YouTube . What do you think? Discuss "Apple uploads individual iPhone 6 and Apple Watch promo videos to YouTube for your embedding ...

Instagram Adds Web Embedding in Bid for Real-Time Relevance
The real-time battle rages on. Instagram on Wednesday announced the latest in a string of recent updates, now allowing users to embed videos ...

The new Android Central Photography forums are open and feature Photosphere embedding
A great place to talk about the camera on your Android phone, and share the great pictures you take with it

Apple granted patent for embedding sapphire displays in LiquidMetal iPhone chassis
The U.S. Patent and Trademark Office on Tuesday issued Apple a patent describing a process in which an iPhone's display glass including sapphire ...

MPAA "embedding is infringement" theory rejected by court
Judge Posner A federal appeals court has decisively rejected a legal theory that would have placed anyone who embeds a third-party video on ...

Resources last updated: 2/10/2016 6:02:45 AM