How to match the keywords in a given sentence to create Schematron expressions XSLT 2.0 or 3.02019 Community Moderator ElectionXSLT 2.0: filter on matchDynamic cast in XSLT 2.0 or 3.0How xslt 2.0 is variable with key value attribute is different from xslt 3.0 map? Which one will perform faster?making a non logic flat structure hierarchicalHow can I use an XSLT variable containing a pattern in a template match expressionHow to use XSLT 3.0 from a Java application?XSLT 2.0 or 3.0 for Node.js?Parsing plain text in CDATA to html with XSLT 2.0/3.0 using multiple steps. Part way thereXSLT converting style down from 3.0 to 2.0 - variable reference errorHow to replace values using templates match using XSLT 2.0 or XSLT 3.0

When were linguistics departments first established

What has been your most complicated TikZ drawing?

Should QA ask requirements to developers?

Making a sword in the stone, in a medieval world without magic

How could a female member of a species produce eggs unto death?

Is it ok to include an epilogue dedicated to colleagues who passed away in the end of the manuscript?

Need some help with my first LaTeX drawing…

Is a lawful good "antagonist" effective?

What exactly is the purpose of connection links straped between the rocket and the launch pad

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Sword in the Stone story where the sword was held in place by electromagnets

Best approach to update all entries in a list that is paginated?

Unreachable code, but reachable with exception

Confusion with the nameplate of an induction motor

Why do Australian milk farmers need to protest supermarkets' milk price?

"One can do his homework in the library"

Potentiometer like component

Do Bugbears' arms literally get longer when it's their turn?

How to deal with a cynical class?

Draw arrow on sides of triangle

What does おとこえしや mean?

Make a transparent 448*448 image

Replacing Windows 7 security updates with anti-virus?

Counter-example to the existence of left Bousfield localization of combinatorial model category



How to match the keywords in a given sentence to create Schematron expressions XSLT 2.0 or 3.0



2019 Community Moderator ElectionXSLT 2.0: filter on matchDynamic cast in XSLT 2.0 or 3.0How xslt 2.0 is variable with key value attribute is different from xslt 3.0 map? Which one will perform faster?making a non logic flat structure hierarchicalHow can I use an XSLT variable containing a pattern in a template match expressionHow to use XSLT 3.0 from a Java application?XSLT 2.0 or 3.0 for Node.js?Parsing plain text in CDATA to html with XSLT 2.0/3.0 using multiple steps. Part way thereXSLT converting style down from 3.0 to 2.0 - variable reference errorHow to replace values using templates match using XSLT 2.0 or XSLT 3.0










1















I have been dealing with an issue for a while that is for a multiple given sentences and keywords, I need to match the keywords and find them in the sentence and create another string,based on the order of the sentence for each keyword.



Thus, the keywords list do not have to follow the same order as in sentence. But the order should match as it is in the sentence. Hope it is clear.



The XML Example:



<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<LIST>
<ID>1</ID>
<MESSAGE>Cats(13) are "lovely" or "beautiful" and Dogs(10) are "loyal" or "friendly".</MESSAGE>
</LIST>
<LIST>
<ID>2</ID>
<MESSAGE>Horses(11) are not a "good" option and Pigs(12) are okay</MESSAGE>
</LIST>
<ADJS>
<ADJ>lovely</ADJ>
</ADJS>
<ADJS>
<ADJ>friendly</ADJ>
</ADJS>
<ADJS>
<ADJ>beautiful</ADJ>
</ADJS>
<ADJS>
<ADJ>loyal</ADJ>
</ADJS>
<ADJS>
<ADJ>good</ADJ>
</ADJS>
<ADJS>
<ADJ>okay</ADJ>
</ADJS>
<KEYWORDS>
<ID>10</ID>
<KEYWORD>Dogs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>11</ID>
<KEYWORD>Horses</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>12</ID>
<KEYWORD>Pigs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>13</ID>
<KEYWORD>Cats</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>14</ID>
<KEYWORD>aquarium</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>b</ID>
<KEYWORD>Fishes</KEYWORD>
</KEYWORDS>
<OP>
<SYNTAX>and</SYNTAX>
</OP>
<OP>
<SYNTAX>or</SYNTAX>
</OP>
<OP>
<SYNTAX>are not</SYNTAX>
</OP>
<OP>
<SYNTAX>are</SYNTAX>
</OP>




XSLT that I kinda tried:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:functx="http://www.functx.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:function name="functx:contains-any-of" as="xs:boolean">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="searchStrings" as="xs:string*"/>
<xsl:sequence select="
some $searchString in $searchStrings
satisfies contains($arg, $searchString)
"/>
</xsl:function>
<xsl:template match="ROOT">
<xsl:variable name="keyID" select="//KEYWORDS/ID"/>
<xsl:variable name="keyName" select="//KEYWORDS/KEYWORD"/>
<xsl:variable name="keyOp" select="//OP/SYNTAX"/>
<xsl:for-each select="//MESSAGE">
<xsl:variable name="message" select="node()"/>
<xsl:if test="functx:contains-any-of($message, $keyID)">

<xsl:element name="test">
<xsl:value-of select="$keyName"/>
<xsl:value-of select="$keyOp"/>
</xsl:element>

</xsl:if>
</xsl:for-each>
</xsl:template>




Expected output:



<test>Cats = ('lovely','beautiful') and Dogs = ('loyal','friendly')</test>
<test>Horses != 'good' or Pigs = 'okay'</test>


The thing is that, everything here is transformed from Excel file, what i am trying to do is to have automatic transformation. from Excel to Schematron. in this part, I already converted the Excel to XML.



Now, I am trying to get Xpath definitions from the sentences, by using the keywords. Because, these keywords are dynamic. If it chances in excel, has to change all the way down to schematron.



I need to find those keywords in the sentences, by the order of sentence. and operators and adjectives as well. So I can create expressions as I tried to show in the expected output.



I cant change the order or the structure of the sentence. The main idea here is to create an Xpath definition out of the sentences.



UPDATE



So I learned from one of the posts of Martin Honnen that in XSLT 2.0, $name = ('Alice', 'Bob', 'Cindy') is possible.



UPDATE-2



<xsl:variable name="operator" select="$btbg/node()/SimpleCodeList/Row/Value[@ColumnRef = 'DictionaryEntryName']/SimpleValue/text()"/>
<xsl:copy>
<xsl:variable name="w" select="tokenize(., 's+')"/>
<xsl:value-of select="$w[position() &gt; index-of($w, $w[. = $operator][1])]"/>
</xsl:copy>


I was thinking about this idea to put the sentence in a loop after it finds the keyword till the end. But also could not make it work. $operator paramater is coming from another XML file. If i do it in this way, I cant get the value recursively. It reads all the operators or any other parameters in the XML.



I want to choose nodes one by one and find them in the sentence. then Cut the sentence there after reading the value, and put the sentence into loop again for the next keyword.



How can I overcome this problem? Thanks in advance.










share|improve this question
























  • Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

    – Martin Honnen
    Mar 7 at 10:37











  • I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

    – Sojimanatsu
    Mar 7 at 10:43












  • Hi Martin, Any ideas ? @MartinHonnen

    – Sojimanatsu
    Mar 8 at 10:51











  • I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

    – Martin Honnen
    Mar 8 at 11:28











  • It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

    – Sojimanatsu
    Mar 9 at 11:30















1















I have been dealing with an issue for a while that is for a multiple given sentences and keywords, I need to match the keywords and find them in the sentence and create another string,based on the order of the sentence for each keyword.



Thus, the keywords list do not have to follow the same order as in sentence. But the order should match as it is in the sentence. Hope it is clear.



The XML Example:



<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<LIST>
<ID>1</ID>
<MESSAGE>Cats(13) are "lovely" or "beautiful" and Dogs(10) are "loyal" or "friendly".</MESSAGE>
</LIST>
<LIST>
<ID>2</ID>
<MESSAGE>Horses(11) are not a "good" option and Pigs(12) are okay</MESSAGE>
</LIST>
<ADJS>
<ADJ>lovely</ADJ>
</ADJS>
<ADJS>
<ADJ>friendly</ADJ>
</ADJS>
<ADJS>
<ADJ>beautiful</ADJ>
</ADJS>
<ADJS>
<ADJ>loyal</ADJ>
</ADJS>
<ADJS>
<ADJ>good</ADJ>
</ADJS>
<ADJS>
<ADJ>okay</ADJ>
</ADJS>
<KEYWORDS>
<ID>10</ID>
<KEYWORD>Dogs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>11</ID>
<KEYWORD>Horses</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>12</ID>
<KEYWORD>Pigs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>13</ID>
<KEYWORD>Cats</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>14</ID>
<KEYWORD>aquarium</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>b</ID>
<KEYWORD>Fishes</KEYWORD>
</KEYWORDS>
<OP>
<SYNTAX>and</SYNTAX>
</OP>
<OP>
<SYNTAX>or</SYNTAX>
</OP>
<OP>
<SYNTAX>are not</SYNTAX>
</OP>
<OP>
<SYNTAX>are</SYNTAX>
</OP>




XSLT that I kinda tried:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:functx="http://www.functx.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:function name="functx:contains-any-of" as="xs:boolean">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="searchStrings" as="xs:string*"/>
<xsl:sequence select="
some $searchString in $searchStrings
satisfies contains($arg, $searchString)
"/>
</xsl:function>
<xsl:template match="ROOT">
<xsl:variable name="keyID" select="//KEYWORDS/ID"/>
<xsl:variable name="keyName" select="//KEYWORDS/KEYWORD"/>
<xsl:variable name="keyOp" select="//OP/SYNTAX"/>
<xsl:for-each select="//MESSAGE">
<xsl:variable name="message" select="node()"/>
<xsl:if test="functx:contains-any-of($message, $keyID)">

<xsl:element name="test">
<xsl:value-of select="$keyName"/>
<xsl:value-of select="$keyOp"/>
</xsl:element>

</xsl:if>
</xsl:for-each>
</xsl:template>




Expected output:



<test>Cats = ('lovely','beautiful') and Dogs = ('loyal','friendly')</test>
<test>Horses != 'good' or Pigs = 'okay'</test>


The thing is that, everything here is transformed from Excel file, what i am trying to do is to have automatic transformation. from Excel to Schematron. in this part, I already converted the Excel to XML.



Now, I am trying to get Xpath definitions from the sentences, by using the keywords. Because, these keywords are dynamic. If it chances in excel, has to change all the way down to schematron.



I need to find those keywords in the sentences, by the order of sentence. and operators and adjectives as well. So I can create expressions as I tried to show in the expected output.



I cant change the order or the structure of the sentence. The main idea here is to create an Xpath definition out of the sentences.



UPDATE



So I learned from one of the posts of Martin Honnen that in XSLT 2.0, $name = ('Alice', 'Bob', 'Cindy') is possible.



UPDATE-2



<xsl:variable name="operator" select="$btbg/node()/SimpleCodeList/Row/Value[@ColumnRef = 'DictionaryEntryName']/SimpleValue/text()"/>
<xsl:copy>
<xsl:variable name="w" select="tokenize(., 's+')"/>
<xsl:value-of select="$w[position() &gt; index-of($w, $w[. = $operator][1])]"/>
</xsl:copy>


I was thinking about this idea to put the sentence in a loop after it finds the keyword till the end. But also could not make it work. $operator paramater is coming from another XML file. If i do it in this way, I cant get the value recursively. It reads all the operators or any other parameters in the XML.



I want to choose nodes one by one and find them in the sentence. then Cut the sentence there after reading the value, and put the sentence into loop again for the next keyword.



How can I overcome this problem? Thanks in advance.










share|improve this question
























  • Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

    – Martin Honnen
    Mar 7 at 10:37











  • I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

    – Sojimanatsu
    Mar 7 at 10:43












  • Hi Martin, Any ideas ? @MartinHonnen

    – Sojimanatsu
    Mar 8 at 10:51











  • I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

    – Martin Honnen
    Mar 8 at 11:28











  • It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

    – Sojimanatsu
    Mar 9 at 11:30













1












1








1








I have been dealing with an issue for a while that is for a multiple given sentences and keywords, I need to match the keywords and find them in the sentence and create another string,based on the order of the sentence for each keyword.



Thus, the keywords list do not have to follow the same order as in sentence. But the order should match as it is in the sentence. Hope it is clear.



The XML Example:



<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<LIST>
<ID>1</ID>
<MESSAGE>Cats(13) are "lovely" or "beautiful" and Dogs(10) are "loyal" or "friendly".</MESSAGE>
</LIST>
<LIST>
<ID>2</ID>
<MESSAGE>Horses(11) are not a "good" option and Pigs(12) are okay</MESSAGE>
</LIST>
<ADJS>
<ADJ>lovely</ADJ>
</ADJS>
<ADJS>
<ADJ>friendly</ADJ>
</ADJS>
<ADJS>
<ADJ>beautiful</ADJ>
</ADJS>
<ADJS>
<ADJ>loyal</ADJ>
</ADJS>
<ADJS>
<ADJ>good</ADJ>
</ADJS>
<ADJS>
<ADJ>okay</ADJ>
</ADJS>
<KEYWORDS>
<ID>10</ID>
<KEYWORD>Dogs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>11</ID>
<KEYWORD>Horses</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>12</ID>
<KEYWORD>Pigs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>13</ID>
<KEYWORD>Cats</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>14</ID>
<KEYWORD>aquarium</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>b</ID>
<KEYWORD>Fishes</KEYWORD>
</KEYWORDS>
<OP>
<SYNTAX>and</SYNTAX>
</OP>
<OP>
<SYNTAX>or</SYNTAX>
</OP>
<OP>
<SYNTAX>are not</SYNTAX>
</OP>
<OP>
<SYNTAX>are</SYNTAX>
</OP>




XSLT that I kinda tried:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:functx="http://www.functx.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:function name="functx:contains-any-of" as="xs:boolean">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="searchStrings" as="xs:string*"/>
<xsl:sequence select="
some $searchString in $searchStrings
satisfies contains($arg, $searchString)
"/>
</xsl:function>
<xsl:template match="ROOT">
<xsl:variable name="keyID" select="//KEYWORDS/ID"/>
<xsl:variable name="keyName" select="//KEYWORDS/KEYWORD"/>
<xsl:variable name="keyOp" select="//OP/SYNTAX"/>
<xsl:for-each select="//MESSAGE">
<xsl:variable name="message" select="node()"/>
<xsl:if test="functx:contains-any-of($message, $keyID)">

<xsl:element name="test">
<xsl:value-of select="$keyName"/>
<xsl:value-of select="$keyOp"/>
</xsl:element>

</xsl:if>
</xsl:for-each>
</xsl:template>




Expected output:



<test>Cats = ('lovely','beautiful') and Dogs = ('loyal','friendly')</test>
<test>Horses != 'good' or Pigs = 'okay'</test>


The thing is that, everything here is transformed from Excel file, what i am trying to do is to have automatic transformation. from Excel to Schematron. in this part, I already converted the Excel to XML.



Now, I am trying to get Xpath definitions from the sentences, by using the keywords. Because, these keywords are dynamic. If it chances in excel, has to change all the way down to schematron.



I need to find those keywords in the sentences, by the order of sentence. and operators and adjectives as well. So I can create expressions as I tried to show in the expected output.



I cant change the order or the structure of the sentence. The main idea here is to create an Xpath definition out of the sentences.



UPDATE



So I learned from one of the posts of Martin Honnen that in XSLT 2.0, $name = ('Alice', 'Bob', 'Cindy') is possible.



UPDATE-2



<xsl:variable name="operator" select="$btbg/node()/SimpleCodeList/Row/Value[@ColumnRef = 'DictionaryEntryName']/SimpleValue/text()"/>
<xsl:copy>
<xsl:variable name="w" select="tokenize(., 's+')"/>
<xsl:value-of select="$w[position() &gt; index-of($w, $w[. = $operator][1])]"/>
</xsl:copy>


I was thinking about this idea to put the sentence in a loop after it finds the keyword till the end. But also could not make it work. $operator paramater is coming from another XML file. If i do it in this way, I cant get the value recursively. It reads all the operators or any other parameters in the XML.



I want to choose nodes one by one and find them in the sentence. then Cut the sentence there after reading the value, and put the sentence into loop again for the next keyword.



How can I overcome this problem? Thanks in advance.










share|improve this question
















I have been dealing with an issue for a while that is for a multiple given sentences and keywords, I need to match the keywords and find them in the sentence and create another string,based on the order of the sentence for each keyword.



Thus, the keywords list do not have to follow the same order as in sentence. But the order should match as it is in the sentence. Hope it is clear.



The XML Example:



<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<LIST>
<ID>1</ID>
<MESSAGE>Cats(13) are "lovely" or "beautiful" and Dogs(10) are "loyal" or "friendly".</MESSAGE>
</LIST>
<LIST>
<ID>2</ID>
<MESSAGE>Horses(11) are not a "good" option and Pigs(12) are okay</MESSAGE>
</LIST>
<ADJS>
<ADJ>lovely</ADJ>
</ADJS>
<ADJS>
<ADJ>friendly</ADJ>
</ADJS>
<ADJS>
<ADJ>beautiful</ADJ>
</ADJS>
<ADJS>
<ADJ>loyal</ADJ>
</ADJS>
<ADJS>
<ADJ>good</ADJ>
</ADJS>
<ADJS>
<ADJ>okay</ADJ>
</ADJS>
<KEYWORDS>
<ID>10</ID>
<KEYWORD>Dogs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>11</ID>
<KEYWORD>Horses</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>12</ID>
<KEYWORD>Pigs</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>13</ID>
<KEYWORD>Cats</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>14</ID>
<KEYWORD>aquarium</KEYWORD>
</KEYWORDS>
<KEYWORDS>
<ID>b</ID>
<KEYWORD>Fishes</KEYWORD>
</KEYWORDS>
<OP>
<SYNTAX>and</SYNTAX>
</OP>
<OP>
<SYNTAX>or</SYNTAX>
</OP>
<OP>
<SYNTAX>are not</SYNTAX>
</OP>
<OP>
<SYNTAX>are</SYNTAX>
</OP>




XSLT that I kinda tried:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:functx="http://www.functx.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:function name="functx:contains-any-of" as="xs:boolean">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="searchStrings" as="xs:string*"/>
<xsl:sequence select="
some $searchString in $searchStrings
satisfies contains($arg, $searchString)
"/>
</xsl:function>
<xsl:template match="ROOT">
<xsl:variable name="keyID" select="//KEYWORDS/ID"/>
<xsl:variable name="keyName" select="//KEYWORDS/KEYWORD"/>
<xsl:variable name="keyOp" select="//OP/SYNTAX"/>
<xsl:for-each select="//MESSAGE">
<xsl:variable name="message" select="node()"/>
<xsl:if test="functx:contains-any-of($message, $keyID)">

<xsl:element name="test">
<xsl:value-of select="$keyName"/>
<xsl:value-of select="$keyOp"/>
</xsl:element>

</xsl:if>
</xsl:for-each>
</xsl:template>




Expected output:



<test>Cats = ('lovely','beautiful') and Dogs = ('loyal','friendly')</test>
<test>Horses != 'good' or Pigs = 'okay'</test>


The thing is that, everything here is transformed from Excel file, what i am trying to do is to have automatic transformation. from Excel to Schematron. in this part, I already converted the Excel to XML.



Now, I am trying to get Xpath definitions from the sentences, by using the keywords. Because, these keywords are dynamic. If it chances in excel, has to change all the way down to schematron.



I need to find those keywords in the sentences, by the order of sentence. and operators and adjectives as well. So I can create expressions as I tried to show in the expected output.



I cant change the order or the structure of the sentence. The main idea here is to create an Xpath definition out of the sentences.



UPDATE



So I learned from one of the posts of Martin Honnen that in XSLT 2.0, $name = ('Alice', 'Bob', 'Cindy') is possible.



UPDATE-2



<xsl:variable name="operator" select="$btbg/node()/SimpleCodeList/Row/Value[@ColumnRef = 'DictionaryEntryName']/SimpleValue/text()"/>
<xsl:copy>
<xsl:variable name="w" select="tokenize(., 's+')"/>
<xsl:value-of select="$w[position() &gt; index-of($w, $w[. = $operator][1])]"/>
</xsl:copy>


I was thinking about this idea to put the sentence in a loop after it finds the keyword till the end. But also could not make it work. $operator paramater is coming from another XML file. If i do it in this way, I cant get the value recursively. It reads all the operators or any other parameters in the XML.



I want to choose nodes one by one and find them in the sentence. then Cut the sentence there after reading the value, and put the sentence into loop again for the next keyword.



How can I overcome this problem? Thanks in advance.







xml xslt-2.0 xslt-3.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Sojimanatsu

















asked Mar 7 at 9:21









SojimanatsuSojimanatsu

176115




176115












  • Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

    – Martin Honnen
    Mar 7 at 10:37











  • I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

    – Sojimanatsu
    Mar 7 at 10:43












  • Hi Martin, Any ideas ? @MartinHonnen

    – Sojimanatsu
    Mar 8 at 10:51











  • I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

    – Martin Honnen
    Mar 8 at 11:28











  • It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

    – Sojimanatsu
    Mar 9 at 11:30

















  • Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

    – Martin Honnen
    Mar 7 at 10:37











  • I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

    – Sojimanatsu
    Mar 7 at 10:43












  • Hi Martin, Any ideas ? @MartinHonnen

    – Sojimanatsu
    Mar 8 at 10:51











  • I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

    – Martin Honnen
    Mar 8 at 11:28











  • It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

    – Sojimanatsu
    Mar 9 at 11:30
















Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

– Martin Honnen
Mar 7 at 10:37





Is the expected output like <test>Cats are "lovely" and Cats are "beautiful" and Dogs are "loyal" and Dogs are "friendly"</test> Schematron? In your question title and in the text you talk about creating Schematron.

– Martin Honnen
Mar 7 at 10:37













I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

– Sojimanatsu
Mar 7 at 10:43






I left a challenging part for myself to change those text operators to "=" "and" "!=" etc. The part I need to create is to test part for schematron validations by the sentences. Sorry if it is confusing. At the end finaly look would be, Cats="lovely" or Cats="lovely" and Dogs="loyal" or Dogs="friendly"

– Sojimanatsu
Mar 7 at 10:43














Hi Martin, Any ideas ? @MartinHonnen

– Sojimanatsu
Mar 8 at 10:51





Hi Martin, Any ideas ? @MartinHonnen

– Sojimanatsu
Mar 8 at 10:51













I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

– Martin Honnen
Mar 8 at 11:28





I am sorry, I don't understand what you want to achieve, for instance why does Horses(11) are not a "good" option translate into Horses = 'good', given that the sentence says not a good option? In general analysing human language with program code seems quite a challenge, something that is beyond my abilities and beyond of what can be achieved in a answer to a stackoverflow post. As you do use XSLT 2, you have more than contains with tokenize and matches and also xsl:analyze-string but regular expressions are not as complex as is human language.

– Martin Honnen
Mar 8 at 11:28













It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

– Sojimanatsu
Mar 9 at 11:30





It is my bad, sorry for the conflicts really. it was really hard to create an example. I fix many things. It is supposed to be != if it is are not of course. In general, the idea is to translate some of the keywords to operators. but the whole process of reading each word has to be in order of the sentence. Thanks for the answers

– Sojimanatsu
Mar 9 at 11:30












0






active

oldest

votes











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%2f55040138%2fhow-to-match-the-keywords-in-a-given-sentence-to-create-schematron-expressions-x%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f55040138%2fhow-to-match-the-keywords-in-a-given-sentence-to-create-schematron-expressions-x%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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page