Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How do I do remote XML Translation in XSL?

From: Peter Flynn <peter.nosp@-.--------.-->
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   "&#160;">
> 	<!ENTITY copy   "&#169;">
> 	<!ENTITY reg    "&#174;">
> 	<!ENTITY trade  "&#8482;">
> 	<!ENTITY mdash  "&#8212;">
> 	<!ENTITY ldquo  "&#8220;">
> 	<!ENTITY rdquo  "&#8221;">
> 	<!ENTITY pound  "&#163;">
> 	<!ENTITY yen    "&#165;">
> 	<!ENTITY euro   "&#8364;">
> ]>

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   "&#160;">
<!ENTITY copy   "&#169;">
<!ENTITY reg    "&#174;">
<!ENTITY trade  "&#8482;">
<!ENTITY mdash  "&#8212;">
<!ENTITY ldquo  "&#8220;">
<!ENTITY rdquo  "&#8221;">
<!ENTITY pound  "&#163;">
<!ENTITY yen    "&#165;">
<!ENTITY euro   "&#8364;">
]>
<?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   "&#160;">
<!ENTITY copy   "&#169;">
<!ENTITY reg    "&#174;">
<!ENTITY trade  "&#8482;">
<!ENTITY mdash  "&#8212;">
<!ENTITY ldquo  "&#8220;">
<!ENTITY rdquo  "&#8221;">
<!ENTITY pound  "&#163;">
<!ENTITY yen    "&#165;">
<!ENTITY euro   "&#8364;">
]>
<?xml-stylesheet type="text/xsl" href="adfare_jobclips.xsl"?>
<dummy/>

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent