Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: XSLT problems ...

Reply
Thread Tools

Re: XSLT problems ...

 
 
Marrow
Guest
Posts: n/a
 
      07-04-2003
Hi Martin,

At the moment your XML is not well-formed - because you have namespace
prefixes where the namespace is not declared (you will have to get this
changed - because if it isn't well-formed XML then it just isn't XML at
all).

Assuming that you had well-formed XML like...

== XML =======================================
<?xml version="1.0"?>
<dummy xmlns:a="aaa" xmlns:b="bbb">
<a>
<a:identiy>
Caption
</a:identiy>
<a:text>
1 first caption
</a:text>
</a>
<b:border>
<a>
<a:text>
here is a lot of text ....
</a:text>
</a>
</b:border>
<a>
<a:identiy>
Caption
</a:identiy>
<a:text>
2 second caption
</a:text>
</a>
<b:border>
<a>
<a:text>
here is a lot of text ....
</a:text>
</a>
</b:border>
</dummy>
== end of XML ================================

Then something like (as a starting point)...

== XSL =======================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="match_a match_b"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:match_a="aaa" xmlns:match_b="bbb">
<xslutput method="xml"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="dummy">
<final>
<xsl:apply-templates select="match_a"/>
</final>
</xsl:template>

<xsl:template match="match_a">
<paragraph>
<caption>
<xsl:value-of select="match_a:text"/>
</caption>
<content>
<xsl:value-of
select="following-sibling::match_b:border[1]/match_a/match_a:text"/>
</content>
</paragraph>
</xsl:template>

</xsl:stylesheet>
== end of XSL ================================

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator




"Buchleitner Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> [xpost: comp.text.xml, microsoft.public.xsl]
>
> Hi!
>
> My Problem:
> I have to use XSLT to transfer a XML-file to be valid to a certain DTD.
> I can not change the XML-file or the DTD ...
> My XML-File looks like:
> <dummy>
> <a>
> <a:identiy>
> Caption
> </a:identiy>
> <a:text>
> 1 first caption
> </a:text>
> </a>
> <b:border>
> <a>
> <a:text>
> here is a lot of text ....
> </a:text>
> </a>
> </b:border>
> <a>
> <a:identiy>
> Caption
> </a:identiy>
> <a:text>
> 2 second caption
> </a:text>
> </a>
> <b:border>
> <a>
> <a:text>
> here is a lot of text ....
> </a:text>
> </a>
> </b:border>
> </dummy>
>
> I have to get a similar XML like this
> <final>
> <paragraph>
> <caption>
> 1 first caption
> </caption>
> <content>
> here is a lot of text ....
> </content>
> </paragraph>
> <paragraph>
> <caption>
> 2 second caption
> </caption>
> <content>
> here is a lot of text ....
> </content>
> </paragraph>
> </final>
>
> My Problem is that either i geht listed all a/a:text elements each time

in
> paragraph/caption or i get listed all b:border/a/a:text elements ...
>
> Has anybody an idea how to solve this?
> That a and b:border would be matched together?
>
>
> TIA, Martin



 
Reply With Quote
 
 
 
 
arnold m. slotnik
Guest
Posts: n/a
 
      07-04-2003
"Marrow" <(E-Mail Removed)> wrote in
news:A9cNa.23120$(E-Mail Removed):

Marrow's solution is a good one, but for the sake of accuracy...

[...]

> At the moment your XML is not well-formed - because you have
> namespace prefixes where the namespace is not declared (you will
> have to get this changed - because if it isn't well-formed XML
> then it just isn't XML at all).


The original XML file *is* well-formed...but it isn't compatible with
a namespace-aware processor. According to the XML 1.0 specification
(see the note in section 2.3), the colon is a name character, but
*should not* (not "must not") be used unless designating a namespace.
XML processors should nevertheless treat the colon as a name
character.

--
a. m. slotnik
 
Reply With Quote
 
 
 
 
Buchleitner Martin
Guest
Posts: n/a
 
      07-04-2003
"Marrow" <(E-Mail Removed)> wrote in message news:<A9cNa.23120$(E-Mail Removed)>...

Hi!
>
> At the moment your XML is not well-formed - because you have namespace
> prefixes where the namespace is not declared (you will have to get this
> changed - because if it isn't well-formed XML then it just isn't XML at
> all).


I had this already in my definition - thanks for reminding

> Hope this helps


It helped

but my problems are still alive because i got a new dtd
e.g.:
<?xml version="1.0"?>
<dummy xmlns:a="aaa" xmlns:b="bbb">
<a>
<a:identiy>
essay
</a:identiy>
<a:text>
this is my essay
</a:text>
<a>
<a:identiy>
Caption
</a:identiy>
<a:text>
1 first caption
</a:text>
</a>
<b:border>
<a>
<a:text>
here is a lot of text ....
</a:text>
</a>
</b:border>
<a>
<a:identiy>
Caption
</a:identiy>
<a:text>
2 second caption
</a:text>
</a>
<b:border>
<a>
<a:text>
here is a lot of text ....
</a:text>
</a>
</b:border>
</dummy>

This should be transformed into
<final>
<essay>
... same stuff like before ...
</essay>
<final>

And in this new DTD there are certain elements who have this property...
last but not least - they are many nested elements of them
and my knowledge of xslt and xpath lacks a lot ...


Thanks anyway, Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments