我正在使用附加了 XSL 的 XML 进行编码。
当我在浏览器(IE + Google Chrome)中打开它时,它会显示白屏。但是,当我在 XML 记事本 2007 中打开相同的文件时,它会显示具有来自 XSL 的正确样式的 XML 数据。
我是否遗漏了有关在浏览器中显示它的内容?
我在顶部有标准声明,我看不出我的代码有什么奇怪的地方;这是一个非常简单的文件,我正在对其进行测试以尝试使其正常工作。
XML 文档
<?xml version = "1.0" encoding ="ISO-8859-1"?>
<?xml-stylesheet type ="text/xsl" href="menu.xslt"?>
<menu>
<food>
<name>Afternoon Tea</name>
<description>Afternoon tea at Cuisine De Paris features a range of handmade mini sandwiches and delicate pastieries served with a selection of world tea</description>
<price>£40</price>
</food>
<food>
<name>Shrimp with sun rippened tomato and salad</name>
<description>A medittearan inspired chef favourite bringing together the intense taste of tomatos with the subtle bite of the shrimp</description>
<price>£20</price>
</food>
<food>
<name>Gold encrusted egg yolk, chicken sand, rye and parmesan</name>
<description>Ipsum</description>
<price>£30</price>
</food>
<food>
<name>Poached egg with couscous and salmon</name>
<description>A delicated poached egg lavished with finiest French sourced cous cous</description>
<price>£25</price>
</food>
<food>
<name>Slow roasted crab with a selection of the restaurant's finest vegetables</name>
<description>Our crab is handmade and rested for two months before it's cooked in a slow cooker in a rich oil</description>
<price>£30</price>
</food>
<food>
<name>Salmon wrapped parcel with white aspargus decorated with peas and a specalist sauce</name>
<description>A slowly smoked salmon sourced ethincally with a punchy English grown white aspargus, topped off with a beautifully cooked trademark sauce</description>
<price>£27</price>
</food>
<food>
<name>Roasted crab with lime</name>
<description>Our signature roasted crab with candied lime is the perfect dinner for a cold winter night</description>
<price>£35</price>
</food>
<food>
<name>Fried cod with roasted sun blushed tomatoes and a green leaf sauce</name>
<description>Our cod is fried in extra virgin oil, looking in all of the richest of the cod with the oil, occampanied by fresh roasted parsnips and authentic mediterrean sun blushed tomatoes.</description>
<price>£40</price>
</food>
<food>
<name>Green pea sauce with pork</name>
<description>Our tender pork has been left to rest for 2 months before being served at Cuisine De Paris, making the succlent flavours shine in this dish. The green pea sauce is the perfect occampy to this tender pork dish.</description>
<price>£33</price>
</food>
<food>
<name>Rabbit with creamy sauce</name>
<description>Slow cooked rabbit in a warm vegetable stock topped with a creamy bread sauce and garnish</description>
<price>£40</price>
</food>
<food>
<name>Beef in a creamy garlic sauce wrapped in a tendor pork shell </name>
<description>Locally sourced beef joints are used to create this infusion of flavours, dressed with a range of heart warmly cooked vegetables</description>
<price>£40</price>
</food>
<food>
<name>Noodles with carrot soup</name>
<description>Authentic Japense transulcent noodles in a freshly made carrot soup infused with giner and cinnamon</description>
<price>£30</price>
</food>
<food>
<name>Salmon served with a pea sauce and vegetables</name>
<description>Our salmon is slowly cooked to look in the richest and flavours with are brought our with the pea sauce and accompaning vegetables</description>
<price>£38</price>
</food>
<food>
<name>Oatmeal caramel stack topped with caramel</name>
<description>Handmade oatcakes layered between a creamy caramel sauce topped with an interuicty designed caramel decoration</description>
<price>£20</price>
</food>
<food>
<name>Vanillia icecream wrapped in shoe pastry encompassed in a vanilla chocolate decoration</name>
<description>Vanilla ice cream handmade to a Cuisine De Paris own recipe with poppy seeds, wrapped in a rich shoe pastry and beautiful decoration</description>
<price>£25</price>
</food>
<food>
<name>A strawberry ice cream swirl with mango icecream</name>
<description>Our delicate strawberry ice cream swirl is a treat for both adults and children a like with an additional handmade mango ice cream for complementary flavours</description>
<price>£25</price>
</food>
<food>
<name>Chocolate sponge in a hot fudge sauce</name>
<description>A light sponge filled with a creamy chocolate mousse bathed in a rich hot fudge sauce</description>
<price>£20</price>
</food>
<food>
<name>A light after dinner pate</name>
<description>A liver and thyme pate is a wonderful option for a savoy dessert with us. With ethically sourced pork to combination of flavours really hits the spot</description>
<price>£23</price>
</food>
<food>
<name>A vanillia mousse wrapped in chocolate shoe pastry on top of an oatmeal biscuit and coffee chocolate ice cream</name>
<description>Our handmade vanillia mousse is the perfect finish to a meal at Cuisine De Paris and with an extragant chocolate dome to complete the dessert the rich flavours will leave you wanting more</description>
<price>£30</price>
</food>
</menu>
XSLT 样式表
<?xml version = "1.0"?>
<xsl:stylesheet version ="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body style="font-family:Arial, helvetica, sans-serif; font-size: 12pt; background-color:#EEEEEE">
<xsl:for-each select="menu/food">
<div style = "background-color:#009134; color:white; padding: 4px">
<span style = "font-weight: bold; color: white">
<xsl:value-of select ="name"/>
</span>
- <xsl:value-of select="price"/>
</div>
<div style = "margin-left: 20px; margin-bottom: 1em; font-size: 10pt">
<xsl:value-of select="description"/>
<span style ="font-style:italic">
(<xsl:value-of select = "price"/> Price per serving)
</span>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
在 IE 中打开显示长行中的 xml 代码(无格式但不是树形),Google Chrome 显示空白页
最佳答案
试试这个,
将符号“£”更改为相应的 unicode 值 £在你的 XML 文件中,然后我得到了结果。
关于xml - 为什么 XML 不显示在浏览器中,但在 XML Notepad 2007 (Microsoft) 中正确显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27720092/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput
我可以得到Infinity和NaNn=9.0/0#=>Infinityn.class#=>Floatm=0/0.0#=>NaNm.class#=>Float但是当我想直接访问Infinity或NaN时:Infinity#=>uninitializedconstantInfinity(NameError)NaN#=>uninitializedconstantNaN(NameError)什么是Infinity和NaN?它们是对象、关键字还是其他东西? 最佳答案 您看到打印为Infinity和NaN的只是Float类的两个特殊实例的字符串
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象