Dear list,
I am having a bit of trouble trying to marshal following kind of XML document: <text font-weight="normal" fill="blue"> This text is normal, <tspan font-weight="bold" fill="red" >but this is bolded,</tspan> while this is normal again. </text> Previously, when we did not have to support the embedded <tspan> element, the following XML-to-Smalltalk binding was ok: <object name="text" smalltalkClass="MEFloatingTextGO"> <attribute name="fill" aspect="svgFill" ref="xsd:string"/> <attribute name="font-weight" aspect="svgFontWeight" ref="xsd:string"/> <text aspect="svgTextSource" ref="xsd:string" /> </object> With <tspan> this does not work - the <tspan> part gets neglected during the marshaling and I get only "This text is normal" and "while this is normal again." parts. I understand that <tspan> requires its own piece of schema, but before that I have to figure it out from the rest of the text somehow. I tried some <element> and <any> variants instead of <text> but with no luck so far. Any ideas of how to solve the problem or what to try next? With best regards, Risto Pohjonen MetaCase |
I don't really know a solution, but maybe you can achieve what you want
with the XPath-expressions mentioned in the doc. But i doubt it, because the <tspan>-element has its own attributes and therefore must be marshaled to an object and not a simple string like the text of the <text>-tag. Maybe you can tell us to what your example should be unmarshaled to? Nevertheless you may consider following strategy: Try not to directly map the XML to the objects you want to use. Instead make intermediate objects which are related 1:1 to the XML-tags. They are used only for marshaling/demarshaling. In your case <tspan> would become a new intermediate object. After reading your XML you can build your Business objects from your intermediate objects using all the power of Smalltalk without any restriction. This has proved useful in the situation you have to marshal and demarshal and want to handle errors yourself. HTH Volker Risto Pohjonen wrote: > Dear list, > > I am having a bit of trouble trying to marshal following kind of XML > document: > > <text font-weight="normal" fill="blue"> > This text is normal, > <tspan font-weight="bold" fill="red" >but this is bolded,</tspan> > while this is normal again. > </text> > > Previously, when we did not have to support the embedded <tspan> > element, the following XML-to-Smalltalk binding was ok: > > <object name="text" smalltalkClass="MEFloatingTextGO"> > <attribute name="fill" aspect="svgFill" ref="xsd:string"/> > <attribute name="font-weight" aspect="svgFontWeight" > ref="xsd:string"/> > <text aspect="svgTextSource" ref="xsd:string" /> > </object> > > With <tspan> this does not work - the <tspan> part gets neglected during > the marshaling and I get only "This text is normal" and "while this is > normal again." parts. I understand that <tspan> requires its own piece > of schema, but before that I have to figure it out from the rest of the > text somehow. I tried some <element> and <any> variants instead of > <text> but with no luck so far. Any ideas of how to solve the problem or > what to try next? > > > With best regards, > > Risto Pohjonen > MetaCase > > > > Volker.Zink.vcf (328 bytes) Download Attachment |
In reply to this post by Risto Pohjonen-2
Volker wrote: >I don't really know a solution, but maybe you can achieve >what you want with the XPath-expressions mentioned in the >doc. But i doubt it, because the <tspan>-element >has its own attributes and therefore must be marshaled to >an object and not a simple string like the text of the ><text>-tag. I checked the XPath-expressions but didn't get too far before it got confusing :-) >Maybe you can tell us to what your example should be unmarshaled to? From the following XML document <text font-weight="normal" fill="blue"> This text is normal, <tspan font-weight="bold" fill="red" >but this is bolded,</tspan> while this is normal again. </text> I should get the whole text of "This text is normal, but this is bolded, while this is normal again" stored (as Text) in an instance variable of an object and properly handle the <tspan> attributes along the way. I have advanced so far that I can get the <tspan> part unmarshaled, but unfortunately that happens separately from the rest of the text and there is no good way to merge these two. >Try not to directly map the XML to the objects you want to use. >Instead make intermediate objects which are related 1:1 to the XML-tags. I am not sure if this solution would work, as the trouble seems to originate from the fact that the <tspan>s are included arbitrary within the <text>. As I said, I can get both <tspan> and non-<tspan> parts unmarshaled now, but not at the same pass. Of course there is always ways to hack around this somehow - and the XPath-expressions seemed to provide some help on this - but to me the situation appears trivial enough that one should be able to handle it on XML-to-Smalltalk-binding level. So, I asked about this directly from Cincom and I am now waiting for their answer before trying out anything ingenious :-) Thanks & best regards, Risto Pohjonen MetaCase |
Free forum by Nabble | Edit this page |