|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Unwanted Prefixes in Output
* Robert Koberg <rob@xxxxxxxxxx> [2005-09-21 05:48]:
> Hi,
>
> Alan wrote:
> >>
> >>> Probably common problem with namespace emissions. Tried to cut
> >>> it down to the basics.
> >>
> >>>I'd like to omit "xmlns:foo" namespace declaration where it will not
> >>>be referenced, like under atom:updated.
> >>
> >> Should note that the saved documents can contain any namespace,
> >> so I can't add xmlns:foo declaration to my stylesheet, but I'd
> >> like to have my namespaces namespace normal.
> >>
> >> http://www.flightlab.com/~joe/sgml/sanity.txt
> >>
> >> Cheers.
> >
> >
> > I'm talking to myself now. :^)
> >
> > I found that this removes unnecessary namespace declarations...
> >
> > <xsl:template match="atom:*" mode="copy-entry">
> > <xsl:element name="atom:{local-name(.)}">
> > <xsl:copy-of select="@*"/>
> > <xsl:apply-templates select="node()" mode="copy-entry"/>
> > </xsl:element>
> > </xsl:template>
>
> I think you want something like:
>
>
> <xsl:template match="atom:*" mode="copy-entry">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates mode="copy-entry"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="*" mode="copy-entry">
> <xsl:element name="{local-name()}" namespace="http://the-atom-namespace">
> <xsl:apply-templates select="@*"/>
> <xsl:apply-templates mode="copy-entry"/>
> </xsl:element>
> </xsl:template>
>
> <xsl:template match="@*">
> <xsl:attribute name="{local-name()}">
> <xsl:value-of select="."/>
> </xsl:attribute>
> </xsl:template>
>
>
> This way you you can put everything in the atom namespace and just
> simplay copy over existiing atom namespaced elements.
>
> is that what you are thinking?
Not quite.
Unknown elements in the Atom namespace make the document invalid
Atom.
Atom allows stuff from other namespaces, that's how you extend it.
I'm aggregating, creating new Atom feeds from different sources.
I've saved the entries in files. Some of the entries have
unpredictable extention namespaces.
Ideal output...
<atom:entry atom:xmlns="http://www.w3.org/2005/Atom"
xmlns:sw="tag:somewhere.com,2005:/extra">
<atom:id>tag:somewhere.com,2005:/feed/article</atom:id>
<atom:link
rel="alternate"
href="http://somewhere.com/feed/article</atom:link>
<sw:extra-info>I like cheese!</sw:extra-info>
<atom:updated>2005-09-20T20:32:10Z</atom:updated>
</atom:entry>
Where I'm at now...
<atom:entry atom:xmlns="http://www.w3.org/2005/Atom">
<atom:id>tag:somewhere.com,2005:/feed/article</atom:id>
<atom:link
rel="alternate"
href="http://somewhere.com/feed/article</atom:link>
<sw:extra-info xmlns:sw="tag:somewhere.com,2005:/extra">I like cheese!</sw:extra-info>
<atom:updated>2005-09-20T20:32:10Z</atom:updated>
</atom:entry>
The fix in the last post made it like the above.
Where I was...
<atom:entry atom:xmlns="http://www.w3.org/2005/Atom">
<atom:id xmlns:sw="tag:somewhere.com,2005:/extra">tag:somewhere.com,2005:/feed/article</atom:id>
<atom:link
xmlns:sw="tag:somewhere.com,2005:/extra"
rel="alternate"
href="http://somewhere.com/feed/article</atom:link>
<sw:extra-info xmlns:sw="tag:somewhere.com,2005:/extra">I like cheese!</sw:extra-info>
<atom:updated xmlns:sw="tag:somewhere.com,2005:/extra">2005-09-20T20:32:10Z</atom:updated>
</atom:entry>
So, I'm happier, but the first version would be "namespace
normal", and that's supposed to be ideal.
Cheers.
--
Alan Gutierrez - alan@xxxxxxxxx
- http://engrm.com/blogometer/index.html
- http://engrm.com/blogometer/rss.2.0.xml
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








