Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: How do I do remote XML Translation in XSL? [Thread Next] Re: How do I do remote XML Translation in XSL?To: NULL Date: 10/16/2007 10:45:00 AM
"Peter Flynn" <peter.nosp@m...> wrote in message
news:5nhvenFie58jU1@m......
> Frank Peterson wrote:
>> I have a XML file on a remote server controlled by a third party. I
>> need to have XSL transform that XML file, yet I havent gotten this to
>> work so far:
>>
>> Local XML:
>> <?xml-stylesheet type="text/xsl" href="adfare_jobclips.xsl"?>
>> <videos>
>> <copyright>this should not show up</copyright>
>> </videos>
>>
>> XSL for Local XML that really points to a 3rd party XML:
>> <?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://
>> example.com/videos.xml" --><!DOCTYPE xsl:stylesheet [
>> <!ENTITY nbsp " ">
>> <!ENTITY copy "©">
>> <!ENTITY reg "®">
>> <!ENTITY trade "™">
>> <!ENTITY mdash "—">
>> <!ENTITY ldquo "“">
>> <!ENTITY rdquo "”">
>> <!ENTITY pound "£">
>> <!ENTITY yen "¥">
>> <!ENTITY euro "€">
>> ]>
>
> That DOCTYPE declaration should be in the local XML file, not in the
> stylesheet, because the entity references may occur in the data, not in
> the stylesheet:
>
> <!DOCTYPE videos [
> <!ENTITY nbsp " ">
> <!ENTITY copy "©">
> <!ENTITY reg "®">
> <!ENTITY trade "™">
> <!ENTITY mdash "—">
> <!ENTITY ldquo "“">
> <!ENTITY rdquo "”">
> <!ENTITY pound "£">
> <!ENTITY yen "¥">
> <!ENTITY euro "€">
> ]>
> <?xml-stylesheet type="text/xsl" href="adfare_jobclips.xsl"?>
> <videos>
> <copyright>this should not show up</copyright>
> </videos>
>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> <xsl:output method="text" encoding="utf-8"/>
>> <xsl:template match="/">
>>
>> <xsl:variable name="XMLFile">http://example.com/videos.xml</xsl:variable>
>> <xsl:for-each select="document($XMLFile)/videos">
>> [{"copyright": <xsl:value-of select="copyright"/>}]
>> </xsl:for-each>
>>
>> </xsl:template>
>> </xsl:stylesheet>
>
> It works, but I don't see the point of referencing the root element type
> "videos" in a for-each, as there can only ever be one root element.
>
> I'm also assuming the local XML is just a dummy, to give XSLT 1.0 a file
> to chew on. In that case, don't confuse the issue by giving it the same
> structure as the remote file. Just say
>
> <!DOCTYPE dummy [
> <!ENTITY nbsp " ">
> <!ENTITY copy "©">
> <!ENTITY reg "®">
> <!ENTITY trade "™">
> <!ENTITY mdash "—">
> <!ENTITY ldquo "“">
> <!ENTITY rdquo "”">
> <!ENTITY pound "£">
> <!ENTITY yen "¥">
> <!ENTITY euro "€">
> ]>
> <?xml-stylesheet type="text/xsl" href="adfare_jobclips.xsl"?>
> <dummy/>
>
> ///Peter
> --
> XML FAQ: http://xml.silmaril.ie/
>
>
And this is poor practice:
<xsl:variable name="XMLFile">http://example.com/videos.xml</
xsl:variable>
should be:
<xsl:variable name="XMLFile" select="'http://example.com/videos.xml'" />
Well it should be a global xsl:param but that's a different story :)
If the actual code isn't working then I suggest you try a simple stylesheet
with one template:
<xsl:template match="/">
<xsl:copy-of select="document('http://example.com/videos.xml')"/>
</xsl:template>
just to make sure you can retrieve the document.
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
