Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - How do I do remote XML Translation in XSL? >Thread Next - Re: How do I do remote XML Translation in XSL? Re: How do I do remote XML Translation in XSL?To: NULL Date: 10/15/2007 9:05:00 PM
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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
