I am building an UWP application with speech recognition capability. I want to reference an external grammar file from within another -root- file.
Here is the code for the root grammar file (named RootGrammar.xml):
<?xml version="1.0" encoding="utf-8"?>
<grammar version="1.0" xml:lang="en-us"
root="topLevel"
xmlns="http://www.w3.org/2001/06/grammar"
tag-format="semantics/1.0"
mode="voice">
<rule id="topLevel">
<item>Hello</item>
<ruleref uri="words.xml"/>
</rule>
</grammar>
And the external grammar file (named words.xml) is:
<?xml version="1.0" encoding="utf-8"?>
<grammar version="1.0" xml:lang="en-us" root="words"
xmlns="http://www.w3.org/2001/06/grammar"
tag-format="semantics/1.0"
mode="voice">
<rule id="words" scope="public">
<one-of>
<item>world</item>
<item>universe</item>
<item>galaxy</item>
</one-of>
</rule>
</grammar>
The two files are located in the same folder (named Grammar), the folder is located on the top level of the solution.
I tried many values for the URI attribute in the root grammar file like:
uri= "/words.xml"
uri= "\words.xml"
uri = "../words.xml"
uri = "..\words.xml"
uri = "ms-appx:///Grammar///words.xml"
I also tried to rename the external file into words.grxml, also tried explicitly identify the rule in the uri (i.e uri = "/words.xml#words") but all of that resulted in GrammarCompilationFailure.
It's by design. When checking the file path references, the only supported URI schemes are file://, http://, and https://. For now, the only solution will likely be to not have external reference files. You also could submit a Feature Request on WPDev UserVoice.
You need to set the file as a Content file. Select the file in the Solution Explorer and in the Properties window set the Build Action to Content.
Then, the proper URI should be:
ms-appx:///Grammar/words.xml
Only the root is three forward slashes (///), then you just use single slash (/).
Related
I am using teiid-wildfly servers. I followed the user defined functions example provided in teiid documentation. Below is my vdb file. Please let me know if I need to import any additional properties to view/access user defined functions. Metadata URL(http://localhost:8080/odata4/UDFTest/JavaCall/$metadata) does not list user defined function and no error in the server log. I created jar file which contains TempConv file implementation and completed the setup under module directory.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vdb name="UDFTest" version="1">
<property name ="lib" value ="org.test"></property>
<model visible="true" name="JavaCall" type="VIRTUAL">
<metadata type="DDL">
<![CDATA[
CREATE VIRTUAL FUNCTION celsiusToFahrenheit(celsius double) RETURNS double OPTIONS (JAVA_CLASS 'org.test.TempConv', JAVA_METHOD 'celsiusToFahrenheit');
]]> </metadata>
</model>
</vdb>
OData has a known issue with exposing functions: see https://issues.redhat.com/browse/TEIID-5736
The workaround would be to use a procedure instead.
Using Saxon 9.9.1.3J, I am getting an I/O error every time I try to transform a DITA file that has a DTD:
I/O error reported by XML parser processing file:/test.dita: /learningAssessment.dtd (No such file or directory)
This happens even if I force -dtd:off on the command line. Commenting out the DTD in the DITA file does allow it to process.
Interestingly, when I run the same DITA file in oXygen using Saxon-HE 9.8.0.12, it does process correctly. Any idea what might be causing this to behave differently?
Sample DITA file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE learningAssessment PUBLIC "-//OASIS//DTD DITA Learning Assessment//EN" "learningAssessment.dtd">
<learningAssessment id="id">
<title>Title</title>
<learningAssessmentbody>
<lcInteraction>
<lcSingleSelect id="lcSingleSelect_agy_fxz_ljb">
<lcQuestion>Question</lcQuestion>
<lcAnswerOptionGroup id="lcAnswerOptionGroup_bgy_fxz_ljb">
<lcAnswerOption>
<lcAnswerContent>A</lcAnswerContent>
</lcAnswerOption>
<lcAnswerOption>
<lcAnswerContent>B</lcAnswerContent>
<lcCorrectResponse/>
</lcAnswerOption>
</lcAnswerOptionGroup>
</lcSingleSelect>
</lcInteraction>
</learningAssessmentbody>
</learningAssessment>
And here's a shell of an XSL that demonstrates the error:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output />
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
You can resolve the problem by the following steps:
Download DITA-OT and expand it any folder you like. In my case it is located at D:\DITA-OT\dita-ot-3.3.4.
Set CLASSPATH environment variable to contain saxon9he.jarand xml-resolver-1.2.jar in DITA-OT/lib.
Invoke Saxon by specifying class name net.sf.saxon.Transform and the catalog: paramter that specifies [DITA-OT]/catalog-dita.xml.
Here is execution example command window:
Hope this helps!
My guess is that you have somehow contrived to give the document a base URI of "file:/test.dita: ", including the final space. You haven't shown how you are running the transformation, so we can't tell where this base URI comes from.
The option -dtd:off is a little misleading. It doesn't switch off DTD processing, only DTD-based validation, which is just one aspect of DTD processing. An XSLT processor always needs to ask the XML parser to read the DTD in order to expand any entity references.
(Well, theoretically it could delay reading any external DTD until it finds the first entity reference; but sadly, I don't know of any XML parser that does that.)
I misunderstood how DTDs work. I assumed the public ones were loaded from an HTTP URL, but they need to be local files. Loading the catalog for DITA OT resolved the issue.
transform -s:test.dita -xsl:test.xsl -o:test.html -catalog:/org.oasis-open.dita.v1_2/plugins/org.oasis-open.dita.v1_2/catalog.xml
Where the catalog option points to this file on my local filesystem, which comes from DITA OT
I have XML file named TIBCOUniversalInstaller_TRA_5.10.0.silent as below.I want to replace values in XML file using "replace" target in ant script using xmltask task.
XML File is below:
<?xml version="1.0"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>---Universal Installer Silent Installation Properties---</comment>
<!--accept the license agreement-->
<entry key="acceptLicense">true</entry>
<entry key="installationRoot">/opt/tibco</entry>
<entry key="environmentName">TRA</entry>
</properties>
At time of parsing XML file ,since my server can not reach java.sun.com , so i had downloaded properties.dtd on my local machine and using xmlcatalog task i am forcing ant script to read local copy of properties.dtd.Below is my ant script
<xmlcatalog id="dtd">
<dtd publicId="SYSTEM" location="/home/tibco/BW-AUTOMATION-
PROJECT/Environments/properties.dtd"/>
</xmlcatalog>
<xmltask source="${TRASoftwareFolder}/TIBCOUniversalInstaller_TRA_5.10.0.silent" dest="${TRASoftwareFolder}/TIBCOUniversalInstaller_TRA_5.10.0.silent">
<xmlcatalog refid="dtd">
</xmlcatalog>
<replace path="/:properties/:entry/:[#key='installationRoot']/text()"
withText="/home/tibco"/>
</xmltask>
But still at time of parsing XML contents , everytime it is going to http://java.sun.com/dtd/properties.dtd and i get "Connection Refused Error".
When i did debug i see below which i believe can be issue and it is always going to website instead of local dtd file.
DEBUG LOGS:
"No matching catalog entry found, parser will use: 'http://java.sun.com/dtd/properties.dtd'"
I believe it is because i gave "SYSTEM" as value in "publicId" attribute inside dtd element.
Can you please advise what should be correct value for "publicID" attribute for this given dtd so that it matches catalog at the time of parsing.
If there is another way of reading/replacing this XML file please advise.
Thanks
This is my crossdomain.xml that I put in the same folder of my Web.config:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" secure="false" />
<allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>
Although I can load using Security.loadPolicyFile("http://localhost:52090/crossdomain.xml").
When my swf try to comunicate with my local site (asp.net mvc) it says:
Error #2048: Security sandbox violation: http:/ /localhost:52090/Content/Swf/MyApp.swf cannot load data from localhost:52090
How do I solve that?
Since you use as3httpclientlib that based on Socket, rather than URLLoader you should setup socket policy server instead of http one (so your crossdomain.xml isn't used by flash in this case).
To setup flash policy server you can use perl script from this article http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html with policy xml suggested by #Bart Friederichs (with to-ports attribute)
Try this one:
<?xml version="1.0"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
also, if you send it yourself, make sure to send a null-character in the end.
I would like to have the following link "http://mywebsite.com/robots.txt" linked to a static file ~/Content/robots.txt.
How can I do this?
Thanks,
Merijn
Adding a route like this should do the trick. This way any static .txt file like robots.txt can be served.
routes.IgnoreRoute("{resource}.txt");
You could install Url Rewrite module:
http://www.iis.net/downloads/microsoft/url-rewrite
Remember that this module works on IIS and not on Cassini/IIS Express.
And add following rule to your web.config to section <system.webServer>
<rewrite>
<rules>
<rule name="robots" stopProcessing="true">
<match url="robots.txt" />
<action type="Rewrite" url="/Content/robots.txt" />
</rule>
</rules>
</rewrite>
I checked it on new MVC 3 .NET project and both url responses with the same file:
mywebsite.com/robots.txt
mywebsite.com/Content/robots.txt
You can setup routing request for disk files. By default the routing system checks to see if the url matches the disk file before evaluating the application's routes. If there is a match the disk file is served and routes are not used. However this can be reveresed so routes are looked at before disk files are checked by setting the RouteExisitingFiles property of RouteCollection to true. Place this statement close to the top of the RegisterRoutes method - this just seems to be convention for mvc apps. Then you define a route that for the disk files. Be aware when doing this that there can some unforseen effects because the riute could natch other kinds of URLs.
Solution 1: If you specify the URL. Browser will request this to IIS or webserver. MVC doesn't participate in the reading file etc. It gives these requests to IIS to handle. You need to assign permission to the folder.
Solution 2: Read the file in the PresentationModel if you have. read this file in Chunks and return as File type to the browser.
I hope it will give you some direction.
I was able to do this by rewriting paths in an event handler for BeginRequest in global.asax.
BeginRequest += delegate
{
switch (Request.RawUrl.ToLowerInvariant())
{
case "/favicon.ico":
Context.RewritePath("~/Content/favicon.ico");
return;
case "/robots.txt":
Context.RewritePath("~/Content/robots.txt");
return;
}
};
routes.MapRoute("Robots","robots.txt");