How can I add a .dtd validation to an .xml file created by a .xq Query?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















So my query was working fine and I now need to verify the resulting .xml with a .dtd validation. My .xq looked like this before:




< root>



...



...



< /root>




Now it looks like this:




< !DOCTYPE root SYSTEM 'validation.dtd'>



< root>



...



...



< /root>




Running the .xq now, however, throws the following error:




XPST0003 XQuery syntax error near #...as xs:integer external; < !D#:



Expected '--' or '[CDATA[' after '< !'



Static error(s) in query




I don't know what this error means, and I'm unable to find how to fix it



Thanks in advance










share|improve this question































    2















    So my query was working fine and I now need to verify the resulting .xml with a .dtd validation. My .xq looked like this before:




    < root>



    ...



    ...



    < /root>




    Now it looks like this:




    < !DOCTYPE root SYSTEM 'validation.dtd'>



    < root>



    ...



    ...



    < /root>




    Running the .xq now, however, throws the following error:




    XPST0003 XQuery syntax error near #...as xs:integer external; < !D#:



    Expected '--' or '[CDATA[' after '< !'



    Static error(s) in query




    I don't know what this error means, and I'm unable to find how to fix it



    Thanks in advance










    share|improve this question



























      2












      2








      2








      So my query was working fine and I now need to verify the resulting .xml with a .dtd validation. My .xq looked like this before:




      < root>



      ...



      ...



      < /root>




      Now it looks like this:




      < !DOCTYPE root SYSTEM 'validation.dtd'>



      < root>



      ...



      ...



      < /root>




      Running the .xq now, however, throws the following error:




      XPST0003 XQuery syntax error near #...as xs:integer external; < !D#:



      Expected '--' or '[CDATA[' after '< !'



      Static error(s) in query




      I don't know what this error means, and I'm unable to find how to fix it



      Thanks in advance










      share|improve this question
















      So my query was working fine and I now need to verify the resulting .xml with a .dtd validation. My .xq looked like this before:




      < root>



      ...



      ...



      < /root>




      Now it looks like this:




      < !DOCTYPE root SYSTEM 'validation.dtd'>



      < root>



      ...



      ...



      < /root>




      Running the .xq now, however, throws the following error:




      XPST0003 XQuery syntax error near #...as xs:integer external; < !D#:



      Expected '--' or '[CDATA[' after '< !'



      Static error(s) in query




      I don't know what this error means, and I'm unable to find how to fix it



      Thanks in advance







      xquery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 '18 at 2:57







      Francisco José Letterio

















      asked Nov 17 '18 at 2:50









      Francisco José LetterioFrancisco José Letterio

      1396




      1396
























          1 Answer
          1






          active

          oldest

          votes


















          3














          To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:



          xquery version "3.1";

          fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })


          This produces the following string:



          <!DOCTYPE root SYSTEM "validation.dtd">
          <root/>


          For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.



          For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:



          xquery version "3.0";

          declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

          fn:serialize(
          <root/>,
          <output:serialization-parameters>
          <output:doctype-system value="validation.dtd"/>
          </output:serialization-parameters>
          )





          share|improve this answer


























          • I can only use XQuery 2, but thanks regardless

            – Francisco José Letterio
            Nov 17 '18 at 19:00











          • Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

            – joewiz
            Nov 17 '18 at 20:59











          • I'm using the Saxon parser

            – Francisco José Letterio
            Nov 17 '18 at 21:00











          • Which version of Saxon?

            – joewiz
            Nov 17 '18 at 21:03






          • 1





            For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

            – joewiz
            Nov 17 '18 at 22:04












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347753%2fhow-can-i-add-a-dtd-validation-to-an-xml-file-created-by-a-xq-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:



          xquery version "3.1";

          fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })


          This produces the following string:



          <!DOCTYPE root SYSTEM "validation.dtd">
          <root/>


          For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.



          For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:



          xquery version "3.0";

          declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

          fn:serialize(
          <root/>,
          <output:serialization-parameters>
          <output:doctype-system value="validation.dtd"/>
          </output:serialization-parameters>
          )





          share|improve this answer


























          • I can only use XQuery 2, but thanks regardless

            – Francisco José Letterio
            Nov 17 '18 at 19:00











          • Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

            – joewiz
            Nov 17 '18 at 20:59











          • I'm using the Saxon parser

            – Francisco José Letterio
            Nov 17 '18 at 21:00











          • Which version of Saxon?

            – joewiz
            Nov 17 '18 at 21:03






          • 1





            For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

            – joewiz
            Nov 17 '18 at 22:04
















          3














          To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:



          xquery version "3.1";

          fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })


          This produces the following string:



          <!DOCTYPE root SYSTEM "validation.dtd">
          <root/>


          For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.



          For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:



          xquery version "3.0";

          declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

          fn:serialize(
          <root/>,
          <output:serialization-parameters>
          <output:doctype-system value="validation.dtd"/>
          </output:serialization-parameters>
          )





          share|improve this answer


























          • I can only use XQuery 2, but thanks regardless

            – Francisco José Letterio
            Nov 17 '18 at 19:00











          • Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

            – joewiz
            Nov 17 '18 at 20:59











          • I'm using the Saxon parser

            – Francisco José Letterio
            Nov 17 '18 at 21:00











          • Which version of Saxon?

            – joewiz
            Nov 17 '18 at 21:03






          • 1





            For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

            – joewiz
            Nov 17 '18 at 22:04














          3












          3








          3







          To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:



          xquery version "3.1";

          fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })


          This produces the following string:



          <!DOCTYPE root SYSTEM "validation.dtd">
          <root/>


          For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.



          For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:



          xquery version "3.0";

          declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

          fn:serialize(
          <root/>,
          <output:serialization-parameters>
          <output:doctype-system value="validation.dtd"/>
          </output:serialization-parameters>
          )





          share|improve this answer















          To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:



          xquery version "3.1";

          fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })


          This produces the following string:



          <!DOCTYPE root SYSTEM "validation.dtd">
          <root/>


          For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.



          For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:



          xquery version "3.0";

          declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

          fn:serialize(
          <root/>,
          <output:serialization-parameters>
          <output:doctype-system value="validation.dtd"/>
          </output:serialization-parameters>
          )






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 17 '18 at 22:09

























          answered Nov 17 '18 at 17:03









          joewizjoewiz

          4,0571220




          4,0571220













          • I can only use XQuery 2, but thanks regardless

            – Francisco José Letterio
            Nov 17 '18 at 19:00











          • Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

            – joewiz
            Nov 17 '18 at 20:59











          • I'm using the Saxon parser

            – Francisco José Letterio
            Nov 17 '18 at 21:00











          • Which version of Saxon?

            – joewiz
            Nov 17 '18 at 21:03






          • 1





            For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

            – joewiz
            Nov 17 '18 at 22:04



















          • I can only use XQuery 2, but thanks regardless

            – Francisco José Letterio
            Nov 17 '18 at 19:00











          • Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

            – joewiz
            Nov 17 '18 at 20:59











          • I'm using the Saxon parser

            – Francisco José Letterio
            Nov 17 '18 at 21:00











          • Which version of Saxon?

            – joewiz
            Nov 17 '18 at 21:03






          • 1





            For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

            – joewiz
            Nov 17 '18 at 22:04

















          I can only use XQuery 2, but thanks regardless

          – Francisco José Letterio
          Nov 17 '18 at 19:00





          I can only use XQuery 2, but thanks regardless

          – Francisco José Letterio
          Nov 17 '18 at 19:00













          Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

          – joewiz
          Nov 17 '18 at 20:59





          Which XQuery processor and version are you using? Many processors implemented their own version before this facility was added to the standard.

          – joewiz
          Nov 17 '18 at 20:59













          I'm using the Saxon parser

          – Francisco José Letterio
          Nov 17 '18 at 21:00





          I'm using the Saxon parser

          – Francisco José Letterio
          Nov 17 '18 at 21:00













          Which version of Saxon?

          – joewiz
          Nov 17 '18 at 21:03





          Which version of Saxon?

          – joewiz
          Nov 17 '18 at 21:03




          1




          1





          For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

          – joewiz
          Nov 17 '18 at 22:04





          For serializing with Saxon in versions that did not yet support XPath 3.0, see the saxon:serialize() function: saxonica.com/html/documentation/functions/saxon/serialize.html. But if you're using Saxon 7.1 or newer, fn:serialize() is supported. You may need an alternative form for specifying the serialization parameters. I'll amend the answer showing this alternate form.

          – joewiz
          Nov 17 '18 at 22:04




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347753%2fhow-can-i-add-a-dtd-validation-to-an-xml-file-created-by-a-xq-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python