From: Donal K. Fellows on
Matthias Meier wrote:
> Can i solve this with 'tdom' (load the xml-data into an tdom and 'dump' it
> according to the dtd)? - or is there any other (tcl) tool?

Sounds like a case for XSLT. Tdom includes an XSLT engine.

Donal.
From: IT(2001)MANIPAL on
On Jun 20, 6:15 pm, "Donal K. Fellows" <donal.k.fell...(a)man.ac.uk>
wrote:
> Matthias Meier wrote:
> > Can i solve this with 'tdom' (load the xml-data into an tdom and 'dump' it
> > according to the dtd)? - or is there any other (tcl) tool?
>
> Sounds like a case for XSLT. Tdom includes an XSLT engine.
>
> Donal.

Hi,

I think Donal is correct, surely this problem can be solve using tdom
lib, its better than XLISt. Though I have one concern, scenario of
duplicate tags with varying numbers, in which tdom is not helping me.
(If you have answer post it)

If the there are multiple tags of same name and at same level you can
read that in some list (ex- nodeList) and then can access it by
something like [ [lindex $nodeList 0] nodeValue ] (for first node and
similarly others too )

but if I have xml as (assume this is a valid XMl)

<tag1>
<taga>a</taga>
<tagb>b</tagb>
<tagc>c</tagc>
<taga>a</taga>
<tagb>b</tagb>
<tagc>c</tagc>
</tag1>
<tag1>
<taga>a</taga>
<tagb>b</tagb>
<tagc>c</tagc>
</tag1>


So here I have multiple taga. I can use the same formula as above by
reading the text() in a single list and then print accordingly. But
that fails here as I am unable to get information that which tag1 is
having how many taga's. As the first one is having 2 and the second
tag1 is having only 1 taga. It was easy if its always similar
distribution.

Any Idea? If we can calculate the sub entry count or descendant count.
I mean first list I will be having of tag1 with 2 entries and second
list of taga with 3 entries. i want to store the identify that first
tag1 is having 2 taga's and secong tag1 is having 1 taga

Thanks in adv
From: Matthias Meier on
Donal K. Fellows schrieb:
> Matthias Meier wrote:
>> Can i solve this with 'tdom' (load the xml-data into an tdom and 'dump' it
>> according to the dtd)? - or is there any other (tcl) tool?
>
> Sounds like a case for XSLT. Tdom includes an XSLT engine.
>

Yep - but how do i get an xslt from an dtd? - or can tdom use a dtd-file as an xslt?

Matthias




From: schlenk on
Matthias Meier wrote:
> Hello,
>
> i have xml-data and neet to transform it so it 'fits' a given dtd.
>
> The main-problem ist that the dtd defines the order of the xml-tags.
>
> I.e the data i have is:
>
> <tag>
> <tag3>c</tag3>
> <tag2>b</tag2>
> <tag1>a</tag2>
> </tag>
>
> The dtd demands the order
>
> <tag>
> <tag1>a</tag2>
> <tag2>b</tag2>
> <tag3>c</tag3>
> </tag>
>
> As the dtd is relatively big (24 included files, app. 8000 lines) i dont really want to 'rewrite' it into my own
> 'transformer'
>
> Can i solve this with 'tdom' (load the xml-data into an tdom and 'dump' it according to the dtd)? - or is there any other (tcl) tool?

So basically you have XML that is well-formed but does not validate
against the DTD and you want to tweak it so it fits the DTD. A good
goal, but usually its the easiest if you start with producing the XML
in the right and valid format to start from.

tdom has tnc as an extension that can validate against a DTD, but i
don't think it can parse a DTD and automatically convert a given XML
DOM tree into that format, because its pretty hard to do that without
lots of guesswork, depending on the amount of differences between your
DTD and your data.

If its just child node ordering and everything else in the XML
document is fine you can probably fix it with some smaller amounts of
scripting, by parsing the DTD and building a list of valid orderings
and than traversing the DOM tree and reorder the nodes at each level.
I would not use xslt for that, but instead use tdoms dom functions to
do it.

But if there is more than child node ordering to be fixed you have to
do more work, maybe a lot more, maybe not, depends very much on your
data and DTD.

Michael


From: IT(2001)MANIPAL on
On Jun 21, 9:52 pm, "IT(2001)MANIPAL" <yash18...(a)gmail.com> wrote:
> On Jun 20, 6:15 pm, "Donal K. Fellows" <donal.k.fell...(a)man.ac.uk>
> wrote:
>
> > Matthias Meier wrote:
> > > Can i solve this with 'tdom' (load thexml-data into antdomand 'dump' it
> > > according to the dtd)? - or is there any other (tcl) tool?
>
> > Sounds like a case for XSLT.Tdomincludes an XSLT engine.
>
> > Donal.
>
> Hi,
>
> I think Donal is correct, surely this problem can be solveusingtdom
> lib, its better than XLISt. Though I have one concern, scenario of
> duplicate tags with varying numbers, in whichtdomis not helping me.
> (If you have answer post it)
>
> If the there are multiple tags of same name and at same level you can
> read that in some list (ex- nodeList) and then can access it by
> something like [ [lindex $nodeList 0] nodeValue ] (for first node and
> similarly others too )
>
> but if I havexmlas (assume this is a validXMl)
>
> <tag1>
>         <taga>a</taga>
>                      <tagb>b</tagb>
>                      <tagc>c</tagc>
>         <taga>a</taga>
>                      <tagb>b</tagb>
>                      <tagc>c</tagc>
> </tag1>
> <tag1>
>         <taga>a</taga>
>                      <tagb>b</tagb>
>                      <tagc>c</tagc>
> </tag1>
>
> So here I have multiple taga. I can use the same formula as above by
> reading the text() in a single list and then print accordingly. But
> that fails here as I am unable to get information that which tag1 is
> having how many taga's. As the first one is having 2 and the second
> tag1 is having only 1 taga. It was easy if its always similar
> distribution.
>
> Any Idea? If we can calculate the sub entry count or descendant count.
> I mean first list I will be having of tag1 with 2 entries and second
> list of taga with 3 entries. i want to store the identify that first
> tag1 is having 2 taga's and secong tag1 is having 1 taga
>
> Thanks in adv

Thanks guys
I was not using the node structure properly. I was every time
accessing the node from root so there was issue of duplicate entries.
Now its fine. i was suppose to reach the parent node which is
duplicate and then for each entry again get list of all sub duplicate
nodes.

There is a better method using XLST you can write a template and then
parse it according to that. Its solve all issues.
 | 
Pages: 1
Prev: synchronize command in Tcl ?
Next: using teacup